aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-04-22 09:43:44 -0500
committerCharles Kerr <charles.kerr@canonical.com>2016-04-22 09:43:44 -0500
commitce5234162fa0c534ff9abf3fce3d03f4b01e893e (patch)
treefa1de28390d3fad05b9a9405190f82cde3fa70e5 /tests
parentb37db33c628675971f118fb3e241dc32a9f0a5d0 (diff)
downloadayatana-indicator-display-ce5234162fa0c534ff9abf3fce3d03f4b01e893e.tar.gz
ayatana-indicator-display-ce5234162fa0c534ff9abf3fce3d03f4b01e893e.tar.bz2
ayatana-indicator-display-ce5234162fa0c534ff9abf3fce3d03f4b01e893e.zip
don't prompt when the greeter's not running yet: change greeter's payload from an 'is_active' bool to a three-value state of active, inactive, and unavailable
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/usb-manager-test.cpp4
-rw-r--r--tests/unit/greeter-test.cpp29
-rw-r--r--tests/utils/gtest-print-helpers.h18
-rw-r--r--tests/utils/mock-greeter.h4
4 files changed, 39 insertions, 16 deletions
diff --git a/tests/integration/usb-manager-test.cpp b/tests/integration/usb-manager-test.cpp
index d62756f..7320640 100644
--- a/tests/integration/usb-manager-test.cpp
+++ b/tests/integration/usb-manager-test.cpp
@@ -206,7 +206,7 @@ TEST_F(UsbManagerFixture, Greeter)
auto adbd_server = std::make_shared<GAdbdServer>(*socket_path, std::vector<std::string>{"PK"+public_key});
// set up a UsbManager to process the request
- m_greeter->m_is_active.set(true);
+ m_greeter->m_state.set(Greeter::State::ACTIVE);
auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor, m_greeter);
// add a signal spy to listen to the notification daemon
@@ -219,7 +219,7 @@ TEST_F(UsbManagerFixture, Greeter)
EXPECT_FALSE(notificationsSpy.wait(2000));
// disable the greeter, the notification should appear
- m_greeter->m_is_active.set(false);
+ m_greeter->m_state.set(Greeter::State::INACTIVE);
wait_for_signals(notificationsSpy, 1);
EXPECT_EQ("Notify", notificationsSpy.at(0).at(0));
notificationsSpy.clear();
diff --git a/tests/unit/greeter-test.cpp b/tests/unit/greeter-test.cpp
index 72df3bc..bfa88e8 100644
--- a/tests/unit/greeter-test.cpp
+++ b/tests/unit/greeter-test.cpp
@@ -18,6 +18,7 @@
*/
#include <tests/utils/qt-fixture.h>
+#include <tests/utils/gtest-print-helpers.h>
#include <src/dbus-names.h>
#include <src/greeter.h>
@@ -110,45 +111,49 @@ protected:
TEST_F(GreeterFixture, ActiveServiceStartsBeforeWatcher)
{
- constexpr bool expected {true};
+ constexpr bool is_active {true};
+ constexpr Greeter::State expected {Greeter::State::ACTIVE};
- start_greeter_service(expected);
+ start_greeter_service(is_active);
UnityGreeter greeter;
- ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.is_active());
+ ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state());
}
TEST_F(GreeterFixture, WatcherStartsBeforeActiveService)
{
- constexpr bool expected {true};
+ constexpr bool is_active {true};
+ constexpr Greeter::State expected {Greeter::State::ACTIVE};
UnityGreeter greeter;
- start_greeter_service(expected);
+ start_greeter_service(is_active);
- ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.is_active());
+ ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state());
}
TEST_F(GreeterFixture, InactiveServiceStartsBeforeWatcher)
{
- constexpr bool expected {false};
+ constexpr bool is_active {false};
+ constexpr Greeter::State expected {Greeter::State::INACTIVE};
- start_greeter_service(expected);
+ start_greeter_service(is_active);
UnityGreeter greeter;
- ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.is_active());
+ ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state());
}
TEST_F(GreeterFixture, WatcherStartsBeforeInactiveService)
{
- constexpr bool expected {false};
+ constexpr bool is_active {false};
+ constexpr Greeter::State expected {Greeter::State::INACTIVE};
UnityGreeter greeter;
- start_greeter_service(expected);
+ start_greeter_service(is_active);
- ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.is_active());
+ ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state());
}
diff --git a/tests/utils/gtest-print-helpers.h b/tests/utils/gtest-print-helpers.h
new file mode 100644
index 0000000..75ee13b
--- /dev/null
+++ b/tests/utils/gtest-print-helpers.h
@@ -0,0 +1,18 @@
+
+#pragma once
+
+#include <src/greeter.h>
+
+inline void PrintTo(const Greeter::State& state, std::ostream* os) {
+ switch(state) {
+ case Greeter::State::ACTIVE: *os << "Active"; break;
+ case Greeter::State::INACTIVE: *os << "Inactive"; break;
+ default: *os << "Unavailable"; break;
+ }
+}
+
+std::ostream& operator<<(std::ostream& os, const Greeter::State& state) {
+ PrintTo(state, &os);
+ return os;
+}
+
diff --git a/tests/utils/mock-greeter.h b/tests/utils/mock-greeter.h
index 5ac85a0..5015087 100644
--- a/tests/utils/mock-greeter.h
+++ b/tests/utils/mock-greeter.h
@@ -26,7 +26,7 @@ class MockGreeter: public Greeter
public:
MockGreeter() =default;
virtual ~MockGreeter() =default;
- core::Property<bool>& is_active() override {return m_is_active;}
- core::Property<bool> m_is_active {false};
+ core::Property<Greeter::State>& state() override {return m_state;}
+ core::Property<Greeter::State> m_state {State::INACTIVE};
};