mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Fix shuffleboard C++ tests, and run them on desktop (#1351)
This commit is contained in:
committed by
Peter Johnson
parent
7b471d8c62
commit
fd82153456
@@ -60,8 +60,8 @@ SimpleWidget& ShuffleboardContainer::Add(
|
||||
|
||||
auto widget = std::make_unique<SimpleWidget>(*this, title);
|
||||
auto ptr = widget.get();
|
||||
widget->GetEntry().SetDefaultValue(defaultValue);
|
||||
m_components.emplace_back(std::move(widget));
|
||||
ptr->GetEntry().SetDefaultValue(defaultValue);
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,11 @@ SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
|
||||
return Add(title, nt::Value::MakeString(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
|
||||
const char* defaultValue) {
|
||||
return Add(title, nt::Value::MakeString(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
|
||||
wpi::ArrayRef<bool> defaultValue) {
|
||||
return Add(title, nt::Value::MakeBooleanArray(defaultValue));
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace frc;
|
||||
ShuffleboardLayout::ShuffleboardLayout(ShuffleboardContainer& parent,
|
||||
const wpi::Twine& name,
|
||||
const wpi::Twine& type)
|
||||
: ShuffleboardValue(name),
|
||||
: ShuffleboardValue(type),
|
||||
ShuffleboardComponent(parent, type, name),
|
||||
ShuffleboardContainer(name) {
|
||||
m_isLayout = true;
|
||||
|
||||
@@ -15,12 +15,11 @@ using namespace frc;
|
||||
|
||||
SimpleWidget::SimpleWidget(ShuffleboardContainer& parent,
|
||||
const wpi::Twine& title)
|
||||
: ShuffleboardValue(title), ShuffleboardWidget(parent, title) {}
|
||||
: ShuffleboardValue(title), ShuffleboardWidget(parent, title), m_entry() {}
|
||||
|
||||
nt::NetworkTableEntry SimpleWidget::GetEntry() {
|
||||
if (!m_entryInitialized) {
|
||||
if (!m_entry) {
|
||||
ForceGenerate();
|
||||
m_entryInitialized = true;
|
||||
}
|
||||
return m_entry;
|
||||
}
|
||||
@@ -28,9 +27,8 @@ nt::NetworkTableEntry SimpleWidget::GetEntry() {
|
||||
void SimpleWidget::BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
|
||||
std::shared_ptr<nt::NetworkTable> metaTable) {
|
||||
BuildMetadata(metaTable);
|
||||
if (!m_entryInitialized) {
|
||||
if (!m_entry) {
|
||||
m_entry = parentTable->GetEntry(GetTitle());
|
||||
m_entryInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class ShuffleboardComponentBase : public virtual ShuffleboardValue {
|
||||
|
||||
protected:
|
||||
wpi::StringMap<std::shared_ptr<nt::Value>> m_properties;
|
||||
bool m_metadataDirty = false;
|
||||
bool m_metadataDirty = true;
|
||||
int m_column = -1;
|
||||
int m_row = -1;
|
||||
int m_width = -1;
|
||||
|
||||
@@ -139,6 +139,18 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
*/
|
||||
SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see #addPersistent(String, Object) add(String title, Object defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
*
|
||||
|
||||
@@ -37,7 +37,6 @@ class SimpleWidget final : public ShuffleboardWidget<SimpleWidget> {
|
||||
|
||||
private:
|
||||
nt::NetworkTableEntry m_entry;
|
||||
bool m_entryInitialized = false;
|
||||
|
||||
void ForceGenerate();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user