summaryrefslogtreecommitdiff
diff options
-rw-r--r--launcher/LauncherControllerPrivate.h2
-rw-r--r--launcher/LauncherModel.h3
-rw-r--r--tests/mock-application.h8
-rw-r--r--tests/test_launcher_controller.cpp17
4 files changed, 16 insertions, 14 deletions
diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h
index 0f567f063..1fda57d2c 100644
--- a/launcher/LauncherControllerPrivate.h
+++ b/launcher/LauncherControllerPrivate.h
@@ -46,7 +46,7 @@ namespace unity
namespace launcher
{
-class Controller::Impl
+class Controller::Impl : public sigc::trackable
{
public:
Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager);
diff --git a/launcher/LauncherModel.h b/launcher/LauncherModel.h
index d093a8047..bc5c832eb 100644
--- a/launcher/LauncherModel.h
+++ b/launcher/LauncherModel.h
@@ -112,8 +112,7 @@ public:
{
std::list<AbstractLauncherIcon::Ptr> result;
- iterator it;
- for (it = begin(); it != end(); it++)
+ for (iterator it = begin(), e = end(); it != e; ++it)
{
T* var = dynamic_cast<T*>((*it).GetPointer());
diff --git a/tests/mock-application.h b/tests/mock-application.h
index 63c7101da..728942cd8 100644
--- a/tests/mock-application.h
+++ b/tests/mock-application.h
@@ -108,6 +108,14 @@ public:
class MockApplicationManager : public unity::ApplicationManager
{
public:
+ static void StartApp(std::string const& desktop_file)
+ {
+ // We know the application manager is a mock one so we can cast it.
+ auto self = dynamic_cast<MockApplicationManager&>(unity::ApplicationManager::Default());
+ auto app = self.GetApplicationForDesktopFile(desktop_file);
+ self.application_started.emit(app);
+ }
+
virtual unity::ApplicationWindowPtr GetActiveWindow()
{
return unity::ApplicationWindowPtr();
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index 31e1201d5..ebdb0f66f 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -1483,19 +1483,14 @@ TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDeviceSection)
TEST_F(TestLauncherController, OnViewOpened)
{
- // This test is too fragile, and should be rewritten with a controlled application manager.
-
- // auto const& app_icons = lc.Impl()->model_->GetSublist<ApplicationLauncherIcon>();
- // auto const& last_app = *(app_icons.rbegin());
-
- // auto app = bamf_matcher_get_application_for_desktop_file(lc.Impl()->matcher_, app::BZR_HANDLE_PATCH.c_str(), TRUE);
- // g_signal_emit_by_name(lc.Impl()->matcher_, "view-opened", app);
- // lc.DisconnectSignals();
+ auto const& app_icons = lc.Impl()->model_->GetSublist<ApplicationLauncherIcon>();
+ auto const& last_app = *(app_icons.rbegin());
- // auto const& icon = lc.GetIconByDesktop(app::BZR_HANDLE_PATCH);
- // ASSERT_TRUE(icon.IsValid());
+ testmocks::MockApplicationManager::StartApp(app::BZR_HANDLE_PATCH);
+ auto const& icon = lc.GetIconByDesktop(app::BZR_HANDLE_PATCH);
+ ASSERT_TRUE(icon.IsValid());
- // ASSERT_EQ(lc.Impl()->model_->IconIndex(icon), lc.Impl()->model_->IconIndex(last_app) + 1);
+ ASSERT_EQ(lc.Impl()->model_->IconIndex(icon), lc.Impl()->model_->IconIndex(last_app) + 1);
}
TEST_F(TestLauncherController, UpdateNumWorkspacesDisable)