Squashed 'third_party/allwpilib_2019/' changes from bd05dfa1c..99e4f7dd2
99e4f7dd2 Fix SPI CS1 not working correctly (#1614)
60c2f5905 C++ CameraServer: initialize default Usb camera device number (#1601)
d55ca191b CameraServer: Add switched camera support (#1600)
e8b24717c C++ Shuffleboard fixes (#1595)
182758c05 Fix Ultrasonic sensor runner thread (#1598)
74f7ba04b Java PIDBase: Make setPIDSourceType and getPIDSourceType public (#1599)
997d4fdf4 Update HAL GetStackTrace to properly report user errors (#1594)
76d9e2663 uv: Add reuse to pipe (#1577)
a230c814c Add support for WPILib vscode extension for allwpilib C++ intellisense (#1590)
12cb77cd7 Fix DS Comm button tests (#1591)
8a9822a96 Allow multiple instances of the same PDP (#1582)
a9371a758 Fix missing exposure property on windows USB cameras (#1571)
6992f5421 cscore: Avoid crash if invalid (null) source set in MjpegServer (#1585)
43696956d Fix Watchdog incorrectly resetting expiration flag upon disable (#1580)
ae3fd5ada Fix docs search having unspecified module directory (#1568)
404666b29 Fix Halsim DS Button Format (#1583)
1eb4c99d1 Update README for 2019 changes (#1569)
910b9f3af Add support for camera descriptions on windows (#1572)
09d90b02f Remove prints and unecessary items from windows GetNetworkInterfaces (#1573)
0e1f9c2ed ntcore: Read ini escaped quotes correctly (#1579)
f156a0011 wpiutil uv: Pass IPC value of listening pipe to accepted pipe (#1576)
4a6087ed5 Disable watchdog test on mac (#1578)
88a09dd13 cscore: Handle USB camera integer menus (#1561)
7d1959636 Changed terminology from "Overload" to "Override" (#1563)
Change-Id: If58e497053b7e80f1f3d6182ad6060a186616a0f
git-subtree-dir: third_party/allwpilib_2019
git-subtree-split: 99e4f7dd2c497d24016b7cb0e6fe16b04d2db1e8
diff --git a/wpilibc/src/test/native/cpp/WatchdogTest.cpp b/wpilibc/src/test/native/cpp/WatchdogTest.cpp
index 141c72e..c796116 100644
--- a/wpilibc/src/test/native/cpp/WatchdogTest.cpp
+++ b/wpilibc/src/test/native/cpp/WatchdogTest.cpp
@@ -83,11 +83,18 @@
TEST(WatchdogTest, IsExpired) {
Watchdog watchdog(0.2, [] {});
+ EXPECT_FALSE(watchdog.IsExpired());
watchdog.Enable();
EXPECT_FALSE(watchdog.IsExpired());
std::this_thread::sleep_for(std::chrono::milliseconds(300));
EXPECT_TRUE(watchdog.IsExpired());
+
+ watchdog.Disable();
+ EXPECT_TRUE(watchdog.IsExpired());
+
+ watchdog.Reset();
+ EXPECT_FALSE(watchdog.IsExpired());
}
TEST(WatchdogTest, Epochs) {
@@ -118,7 +125,11 @@
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
}
+#ifdef __APPLE__
+TEST(WatchdogTest, DISABLED_MultiWatchdog) {
+#else
TEST(WatchdogTest, MultiWatchdog) {
+#endif
uint32_t watchdogCounter1 = 0;
uint32_t watchdogCounter2 = 0;
diff --git a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp
new file mode 100644
index 0000000..3dd9dbf
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp
@@ -0,0 +1,65 @@
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) 2018 FIRST. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
+#include <array>
+#include <memory>
+#include <string>
+
+#include <networktables/NetworkTableEntry.h>
+#include <networktables/NetworkTableInstance.h>
+
+#include "frc/commands/InstantCommand.h"
+#include "frc/shuffleboard/BuiltInWidgets.h"
+#include "frc/shuffleboard/ShuffleboardInstance.h"
+#include "frc/shuffleboard/ShuffleboardTab.h"
+#include "frc/shuffleboard/ShuffleboardWidget.h"
+#include "frc/smartdashboard/Sendable.h"
+#include "gtest/gtest.h"
+
+using namespace frc;
+
+class ShuffleboardWidgetTest : public testing::Test {
+ void SetUp() override {
+ m_ntInstance = nt::NetworkTableInstance::Create();
+ m_instance = std::make_unique<detail::ShuffleboardInstance>(m_ntInstance);
+ m_tab = &(m_instance->GetTab("Tab"));
+ }
+
+ protected:
+ nt::NetworkTableInstance m_ntInstance;
+ ShuffleboardTab* m_tab;
+ std::unique_ptr<detail::ShuffleboardInstance> m_instance;
+};
+
+TEST_F(ShuffleboardWidgetTest, UseBuiltInWidget) {
+ auto entry =
+ m_tab->Add("Name", "").WithWidget(BuiltInWidgets::kTextView).GetEntry();
+ EXPECT_EQ("/Shuffleboard/Tab/Name", entry.GetName())
+ << "The widget entry has the wrong name";
+}
+
+TEST_F(ShuffleboardWidgetTest, WithProperties) {
+ wpi::StringMap<std::shared_ptr<nt::Value>> properties{
+ std::make_pair("min", nt::Value::MakeDouble(0)),
+ std::make_pair("max", nt::Value::MakeDouble(1))};
+ auto entry =
+ m_tab->Add("WithProperties", "").WithProperties(properties).GetEntry();
+
+ // Update the instance to generate
+ // the metadata entries for the widget properties
+ m_instance->Update();
+
+ auto propertiesTable = m_ntInstance.GetTable(
+ "/Shuffleboard/.metadata/Tab/WithProperties/Properties");
+
+ EXPECT_EQ("/Shuffleboard/Tab/WithProperties", entry.GetName())
+ << "The widget entry has the wrong name";
+ EXPECT_FLOAT_EQ(0, propertiesTable->GetEntry("min").GetDouble(-1))
+ << "The 'min' property should be 0";
+ EXPECT_FLOAT_EQ(1, propertiesTable->GetEntry("max").GetDouble(-1))
+ << "The 'max' property should be 1";
+}