aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/glib-fixture.h2
-rw-r--r--tests/gtestdbus-fixture.h102
-rw-r--r--tests/manual24
-rw-r--r--tests/test-rotation-lock.cpp (renamed from tests/test-hello-world.cpp)23
5 files changed, 131 insertions, 24 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 38c315c..054a676 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -29,7 +29,7 @@ function(add_test_by_name name)
add_dependencies (${TEST_NAME} libindicatordisplayservice)
target_link_libraries (${TEST_NAME} indicatordisplayservice ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
endfunction()
-add_test_by_name(test-hello-world)
+add_test_by_name(test-rotation-lock)
-add_test (cppcheck cppcheck --enable=all -q --error-exitcode=2 --inline-suppr -I${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
+add_test (cppcheck cppcheck --enable=all -q --error-exitcode=2 --inline-suppr -I${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h
index 4c53244..a8f3a76 100644
--- a/tests/glib-fixture.h
+++ b/tests/glib-fixture.h
@@ -84,6 +84,8 @@ class GlibFixture : public ::testing::Test
g_log_set_default_handler(default_log_handler, this);
+ g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));
+
g_unsetenv("DISPLAY");
}
diff --git a/tests/gtestdbus-fixture.h b/tests/gtestdbus-fixture.h
new file mode 100644
index 0000000..541050e
--- /dev/null
+++ b/tests/gtestdbus-fixture.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#include "glib-fixture.h"
+
+/***
+****
+***/
+
+class GTestDBusFixture: public GlibFixture
+{
+ public:
+
+ GTestDBusFixture() {}
+
+ GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {}
+
+ private:
+
+ typedef GlibFixture super;
+
+ static void
+ on_bus_opened (GObject* /*object*/, GAsyncResult * res, gpointer gself)
+ {
+ auto self = static_cast<GTestDBusFixture*>(gself);
+
+ GError * err = 0;
+ self->bus = g_bus_get_finish (res, &err);
+ g_assert_no_error (err);
+
+ g_main_loop_quit (self->loop);
+ }
+
+ static void
+ on_bus_closed (GObject* /*object*/, GAsyncResult * res, gpointer gself)
+ {
+ auto self = static_cast<GTestDBusFixture*>(gself);
+
+ GError * err = 0;
+ g_dbus_connection_close_finish (self->bus, res, &err);
+ g_assert_no_error (err);
+
+ g_main_loop_quit (self->loop);
+ }
+
+ protected:
+
+ GTestDBus * test_dbus = nullptr;
+ GDBusConnection * bus = nullptr;
+ const std::vector<std::string> service_dirs;
+
+ virtual void SetUp ()
+ {
+ super::SetUp ();
+
+ // pull up a test dbus
+ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+ for (const auto& dir : service_dirs)
+ g_test_dbus_add_service_dir (test_dbus, dir.c_str());
+ g_test_dbus_up (test_dbus);
+ const char * address = g_test_dbus_get_bus_address (test_dbus);
+ g_setenv ("DBUS_SYSTEM_BUS_ADDRESS", address, true);
+ g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, true);
+ g_debug ("test_dbus's address is %s", address);
+
+ // wait for the GDBusConnection before returning
+ g_bus_get (G_BUS_TYPE_SYSTEM, nullptr, on_bus_opened, this);
+ g_main_loop_run (loop);
+ }
+
+ virtual void TearDown ()
+ {
+ wait_msec();
+
+ // close the system bus
+ g_dbus_connection_close(bus, nullptr, on_bus_closed, this);
+ g_main_loop_run(loop);
+ g_clear_object(&bus);
+
+ // tear down the test dbus
+ g_test_dbus_down(test_dbus);
+ g_clear_object(&test_dbus);
+
+ super::TearDown();
+ }
+};
diff --git a/tests/manual b/tests/manual
index fc81e6e..a0e5264 100644
--- a/tests/manual
+++ b/tests/manual
@@ -1,24 +1,14 @@
-Test-case indicator-transfer/simple-download-check
+Test-case indicator-datetime/rotation-indicator
<dl>
- <dt>Ensure indicator-transfer-service is running<dt>
- <dd>The indicator should be visible in the panel</dd>
+ <dt>On the phone, enable the orientation lock in ubuntu-system-settings.</dt>
+ <dd>The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.</dd>
- <dt>Run the script tests/simple-download.py and, immediately afterwards,
- click or pull down on the indicator so that its menu is visible
- and its menuitems can be observed while the downloads run.</dt>
- <dd>In the 'Ongoing Transfers' section, the transfers should appear</dd>
- <dd>In the 'Ongoing Transfers' section, a 'Pause all' button should appear</dd>
- <dd>While transfers are active, the indicator's icon should indicate activity</dd>
- <dd>As each transfer finishes, its menuitem should move from the 'Ongoing' to 'Successful' section</dd>
- <dd>As the first transfer is moved to the 'Successful' section, a 'Clear all' button should appear</dd>
- <dd>As the last transfer finishes, the indicator's icon should change to indicate an idle state</dd>
- <dd>As the last transfer finishes, the 'Pause all' button should disappear</dd>
+ <dt>With the orientation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd>
+ <dd>The rotation lock indicator should disappear</dd>
+ <dd>In ubuntu-system-settings, the orientation lock control should change to 'none'.</dd>
+</dl>
- <dt>After all the transfers finish, press the 'Clear all' button.</dt>
- <dd>All three transfers should be cleared from the menu.</dd>
- <dd>The 'Clear all' button should disappear</dd>
-</dt>
<strong>
If all actions produce the expected results listed, please <a href="results#add_result">submit</a> a 'passed' result.
diff --git a/tests/test-hello-world.cpp b/tests/test-rotation-lock.cpp
index 5d9c308..946b1dd 100644
--- a/tests/test-hello-world.cpp
+++ b/tests/test-rotation-lock.cpp
@@ -17,12 +17,14 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#include "glib-fixture.h"
+#include "gtestdbus-fixture.h"
-class HelloWorldFixture: public GlibFixture
+#include <src/rotation-lock.h>
+
+class RotationLockFixture: public GTestDBusFixture
{
private:
- typedef GlibFixture super;
+ typedef GTestDBusFixture super;
protected:
@@ -41,8 +43,19 @@ protected:
****
***/
-TEST_F(HelloWorldFixture, HelloWorld)
+TEST_F(RotationLockFixture, CheckIndicator)
{
- EXPECT_TRUE(true);
+ RotationLockIndicator indicator;
+
+ ASSERT_STREQ("rotation_lock", indicator.name());
+ auto actions = indicator.action_group();
+ ASSERT_TRUE(actions != nullptr);
+ ASSERT_TRUE(g_action_group_has_action(G_ACTION_GROUP(actions), "rotation-lock"));
+
+ std::vector<std::shared_ptr<Profile>> profiles = indicator.profiles();
+ ASSERT_EQ(1, profiles.size());
+ std::shared_ptr<Profile> phone = profiles[0];
+ ASSERT_EQ(std::string("phone"), phone->name());
+ ASSERT_FALSE(phone->header()->is_visible);
}