summaryrefslogtreecommitdiff
path: root/tests
diff options
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/data/applications/org.gnome.Software.desktop (renamed from tests/data/applications/ubuntu-software-center.desktop)7
-rw-r--r--tests/mock-application.h14
-rw-r--r--tests/test_application_launcher_icon.cpp59
-rw-r--r--tests/test_desktop_utilities.cpp6
-rw-r--r--tests/test_favorite_store.cpp2
-rw-r--r--tests/test_favorite_store_gsettings.cpp2
-rw-r--r--tests/test_gnome_session_manager.cpp32
-rw-r--r--tests/test_launcher_controller.cpp135
-rw-r--r--tests/test_lockscreen_controller.cpp19
-rw-r--r--tests/test_mock_devices.h2
-rw-r--r--tests/test_mock_filemanager.h13
-rw-r--r--tests/test_mock_session_manager.h3
-rw-r--r--tests/test_previews_application.cpp2
-rw-r--r--tests/test_software_center_launcher_icon.cpp135
-rw-r--r--tests/test_switcher_controller.h22
-rw-r--r--tests/test_switcher_controller_class.cpp27
-rw-r--r--tests/test_trash_launcher_icon.cpp74
-rw-r--r--tests/test_unity_settings.cpp10
-rw-r--r--tests/test_volume_launcher_icon.cpp188
20 files changed, 447 insertions, 306 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9bcf0a582..17ea9b758 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -80,6 +80,7 @@ if (GMOCK_LIB AND
set (GTEST_SLOW_SOURCES
test_main.cpp
logger_helper.cpp
+ mock-application.cpp
test_switcher_controller_slow.cpp
test_switcher_controller_class.cpp
test_tooltip_manager.cpp
diff --git a/tests/data/applications/ubuntu-software-center.desktop b/tests/data/applications/org.gnome.Software.desktop
index d633a43ac..7481fd62d 100644
--- a/tests/data/applications/ubuntu-software-center.desktop
+++ b/tests/data/applications/org.gnome.Software.desktop
@@ -1,9 +1,8 @@
[Desktop Entry]
-Name=Ubuntu Software Center
-GenericName=Software Center
-Comment=Lets you choose from thousands of applications available for Ubuntu
+Name=Software
+Comment=Add, remove or update software on this computer
Exec=/bin/true
-Icon=softwarecenter
+Icon=org.gnome.Software
Terminal=false
Type=Application
Categories=PackageManager;GTK;System;Settings;
diff --git a/tests/mock-application.h b/tests/mock-application.h
index 312168854..0ee200f9d 100644
--- a/tests/mock-application.h
+++ b/tests/mock-application.h
@@ -91,7 +91,7 @@ struct MockApplicationWindow : unity::ApplicationWindow
return;
title_ = new_title;
- title.changed(title_);
+ title.changed.emit(title_);
}
void SetIcon(std::string const& new_icon)
@@ -100,7 +100,16 @@ struct MockApplicationWindow : unity::ApplicationWindow
return;
icon_ = new_icon;
- icon.changed(icon_);
+ icon.changed.emit(icon_);
+ }
+
+ void SetMonitor(int new_monitor)
+ {
+ if (monitor_ == new_monitor)
+ return;
+
+ monitor_ = new_monitor;
+ monitor.changed.emit(monitor_);
}
};
@@ -329,6 +338,7 @@ struct MockApplicationManager : public unity::ApplicationManager
MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr());
MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int));
MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window));
+ MOCK_CONST_METHOD3(FocusWindowGroup, void(unity::WindowList const&, bool, int));
unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file)
{
diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp
index 41688d36d..610417c91 100644
--- a/tests/test_application_launcher_icon.cpp
+++ b/tests/test_application_launcher_icon.cpp
@@ -41,7 +41,7 @@ using namespace unity::launcher;
namespace
{
const std::string DEFAULT_EMPTY_ICON = "application-default-icon";
-const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop";
+const std::string GS_DESKTOP = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop";
const std::string UM_DESKTOP = BUILDDIR"/tests/data/applications/update-manager.desktop";
const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop";
@@ -50,7 +50,8 @@ struct MockApplicationLauncherIcon : ApplicationLauncherIcon
typedef nux::ObjectPtr<MockApplicationLauncherIcon> Ptr;
MockApplicationLauncherIcon(ApplicationPtr const& app)
- : ApplicationLauncherIcon(app)
+ : WindowedLauncherIcon(IconType::APPLICATION)
+ , ApplicationLauncherIcon(app)
{
ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); }));
ON_CALL(*this, Stick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::Stick(); }));
@@ -67,11 +68,14 @@ struct MockApplicationLauncherIcon : ApplicationLauncherIcon
bool LauncherIconIsSticky() const { return LauncherIcon::IsSticky(); }
void LocalActivate(ActionArg a) { ApplicationLauncherIcon::ActivateLauncherIcon(a); }
- using ApplicationLauncherIcon::IsFileManager;
using ApplicationLauncherIcon::LogUnityEvent;
using ApplicationLauncherIcon::Remove;
using ApplicationLauncherIcon::SetApplication;
using ApplicationLauncherIcon::GetApplication;
+ using ApplicationLauncherIcon::PerformScroll;
+ using LauncherIcon::BackgroundColor;
+ using LauncherIcon::GetRemoteUri;
+ using LauncherIcon::AllowDetailViewInSwitcher;
};
MATCHER_P(AreArgsEqual, a, "")
@@ -89,16 +93,16 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase
virtual void SetUp() override
{
- usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter");
- usc_icon = new NiceMock<MockApplicationLauncherIcon>(usc_app);
- ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP);
+ usc_app = std::make_shared<MockApplication::Nice>(GS_DESKTOP, "org.gnome.Software");
+ usc_icon = new MockApplicationLauncherIcon(usc_app);
+ ASSERT_EQ(usc_icon->DesktopFile(), GS_DESKTOP);
empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP);
- empty_icon = new NiceMock<MockApplicationLauncherIcon>(empty_app);
+ empty_icon = new MockApplicationLauncherIcon(empty_app);
ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP);
mock_app = std::make_shared<MockApplication::Nice>();
- mock_icon = new NiceMock<MockApplicationLauncherIcon>(mock_app);
+ mock_icon = new MockApplicationLauncherIcon(mock_app);
ASSERT_TRUE(mock_icon->DesktopFile().empty());
}
@@ -171,9 +175,9 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase
TEST_F(TestApplicationLauncherIcon, ApplicationSignalDisconnection)
{
- std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP);
+ std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(GS_DESKTOP);
{
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
+ MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
EXPECT_FALSE(app->closed.empty());
}
@@ -197,7 +201,7 @@ TEST_F(TestApplicationLauncherIcon, TestCustomBackgroundColor)
TEST_F(TestApplicationLauncherIcon, TestDefaultIcon)
{
- EXPECT_EQ(usc_icon->icon_name(), "softwarecenter");
+ EXPECT_EQ(usc_icon->icon_name(), "org.gnome.Software");
EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON);
EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON);
}
@@ -263,10 +267,10 @@ TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessApp)
TEST_F(TestApplicationLauncherIcon, StickStickedDesktopApp)
{
- auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP);
+ auto app = std::make_shared<MockApplication::Nice>(GS_DESKTOP);
app->sticky = true;
app->desktop_file_ = UM_DESKTOP;
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
+ MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
ASSERT_TRUE(icon->IsSticky());
EXPECT_TRUE(icon->LauncherIconIsSticky());
}
@@ -275,7 +279,7 @@ TEST_F(TestApplicationLauncherIcon, StickStickedDesktopLessApp)
{
auto app = std::make_shared<MockApplication::Nice>();
app->sticky = true;
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
+ MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
ASSERT_FALSE(icon->IsSticky());
EXPECT_FALSE(icon->LauncherIconIsSticky());
}
@@ -291,7 +295,7 @@ TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopAppDontCreateNewDesktop)
TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessAppCreatesNewDesktop)
{
auto app = std::make_shared<MockApplication::Nice>();
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
+ MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
EXPECT_CALL(*app, CreateLocalDesktopFile());
icon->Stick(true);
@@ -354,7 +358,7 @@ TEST_F(TestApplicationLauncherIcon, UnstickDesktopAppLogEvents)
TEST_F(TestApplicationLauncherIcon, UnstickDesktopLessAppLogEvent)
{
auto app = std::make_shared<MockApplication::Nice>();
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
+ MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)).Times(0);
icon->UnStick();
@@ -538,7 +542,7 @@ TEST_F(TestApplicationLauncherIcon, UpdateDesktopForgetsOldPositionUpdatesUriAnd
TEST_F(TestApplicationLauncherIcon, RemoteUri)
{
- EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + USC_DESKTOP);
+ EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + GS_DESKTOP);
EXPECT_TRUE(mock_icon->RemoteUri().empty());
}
@@ -1103,25 +1107,6 @@ TEST_F(TestApplicationLauncherIcon, QuicklistMenuItemRemoteOverridesQuitByProper
dbusmenu_menuitem_handle_event(item, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
}
-TEST_F(TestApplicationLauncherIcon, IsFileManager)
-{
- EXPECT_FALSE(usc_icon->IsFileManager());
- EXPECT_FALSE(empty_icon->IsFileManager());
- EXPECT_FALSE(mock_icon->IsFileManager());
-
- auto app = std::make_shared<MockApplication::Nice>("/any/path/org.gnome.Nautilus.desktop", "Nautilus");
- MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app));
- EXPECT_TRUE(icon->IsFileManager());
-
- app = std::make_shared<MockApplication::Nice>("/any/path/nautilus-folder-handler.desktop", "Nautilus");
- icon = new NiceMock<MockApplicationLauncherIcon>(app);
- EXPECT_TRUE(icon->IsFileManager());
-
- app = std::make_shared<MockApplication::Nice>("/any/path/nautilus-home.desktop", "Nautilus");
- icon = new NiceMock<MockApplicationLauncherIcon>(app);
- EXPECT_TRUE(icon->IsFileManager());
-}
-
TEST_F(TestApplicationLauncherIcon, AllowDetailViewInSwitcher)
{
mock_app->type_ = AppType::NORMAL;
@@ -1232,7 +1217,7 @@ TEST_F(TestApplicationLauncherIcon, DestructionDontUnsetsAppSeenIfReplaced)
mock_icon->Remove();
ASSERT_FALSE(mock_app->seen);
- MockApplicationLauncherIcon::Ptr new_icon(new NiceMock<MockApplicationLauncherIcon>(mock_app));
+ MockApplicationLauncherIcon::Ptr new_icon(new MockApplicationLauncherIcon(mock_app));
mock_icon = nullptr;
EXPECT_TRUE(mock_app->seen);
diff --git a/tests/test_desktop_utilities.cpp b/tests/test_desktop_utilities.cpp
index b8726b943..f77b9ac3e 100644
--- a/tests/test_desktop_utilities.cpp
+++ b/tests/test_desktop_utilities.cpp
@@ -184,17 +184,17 @@ TEST(TestDesktopUtilities, TestGetDesktopPathById)
g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE);
g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE);
- std::string const& file = DesktopUtilities::GetDesktopPathById("ubuntu-software-center.desktop");
+ std::string const& file = DesktopUtilities::GetDesktopPathById("org.gnome.Software.desktop");
g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE);
g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE);
- EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/ubuntu-software-center.desktop");
+ EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/org.gnome.Software.desktop");
}
TEST(TestDesktopUtilities, TestGetBackgroundColor)
{
- std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop");
+ std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop");
EXPECT_EQ(color, "#aabbcc");
}
diff --git a/tests/test_favorite_store.cpp b/tests/test_favorite_store.cpp
index 3fd0d1bd3..da9089189 100644
--- a/tests/test_favorite_store.cpp
+++ b/tests/test_favorite_store.cpp
@@ -87,7 +87,7 @@ TEST_F(TestFavoriteStore, IsValidFavoriteUri)
TEST_F(TestFavoriteStore, ParseFavoriteFromUri)
{
- const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop";
+ const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop";
EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop");
EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH);
diff --git a/tests/test_favorite_store_gsettings.cpp b/tests/test_favorite_store_gsettings.cpp
index 9f9c1b4b0..a1b584238 100644
--- a/tests/test_favorite_store_gsettings.cpp
+++ b/tests/test_favorite_store_gsettings.cpp
@@ -38,7 +38,7 @@ const gchar* SETTINGS_NAME = "com.canonical.Unity.Launcher";
const gchar* SETTINGS_KEY = "favorites";
const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop",
- "file://" BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop",
+ "file://" BUILDDIR "/tests/data/applications/org.gnome.Software.desktop",
"application://" BUILDDIR "/tests/data/applications/update-manager.desktop",
"unity://test-icon",
"device://uuid",
diff --git a/tests/test_gnome_session_manager.cpp b/tests/test_gnome_session_manager.cpp
index d44c3b7ec..e009ab483 100644
--- a/tests/test_gnome_session_manager.cpp
+++ b/tests/test_gnome_session_manager.cpp
@@ -42,6 +42,7 @@ const std::string LOGIND_SESSION_PATH = "/org/freedesktop/login1/session/id0";
const std::string CONSOLE_KIT_PATH = "/org/freedesktop/ConsoleKit/Manager";
const std::string SESSION_MANAGER_PATH = "/org/gnome/SessionManager";
const std::string SESSION_MANAGER_PRESENCE_PATH = "/org/gnome/SessionManager/Presence";
+const std::string DISPLAY_MANAGER_SEAT_PATH = "/org/freedesktop/DisplayManager/Seat0";
const std::string SESSION_OPTIONS = "com.canonical.indicator.session";
const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown";
@@ -137,6 +138,13 @@ R"(<node>
</node>
)";
+const std::string DISPLAY_MANAGER_SEAT =
+R"(<node>
+ <interface name="org.freedesktop.DisplayManager.Seat">
+ <method name="SwitchToGreeter"/>
+ </interface>
+</node>
+)";
}
struct MockGnomeSessionManager : session::GnomeManager {
@@ -208,6 +216,9 @@ struct TestGnomeSessionManager : testing::Test
return nullptr;
});
+ display_manager_seat_ = std::make_shared<DBusServer>();
+ display_manager_seat_->AddObjects(introspection::DISPLAY_MANAGER_SEAT, DISPLAY_MANAGER_SEAT_PATH);
+
manager = std::make_shared<MockGnomeSessionManager>();
shell_proxy_ = std::make_shared<DBusProxy>(TEST_SERVER_NAME, SHELL_OBJECT_PATH, SHELL_INTERFACE);
@@ -228,6 +239,7 @@ struct TestGnomeSessionManager : testing::Test
Utils::WaitUntilMSec([] { return logind_->IsConnected(); });
Utils::WaitUntilMSec([] { return console_kit_->IsConnected(); });
Utils::WaitUntilMSec([] { return session_manager_->IsConnected(); });
+ Utils::WaitUntilMSec([] { return display_manager_seat_->IsConnected(); });
Utils::WaitUntilMSec([] { return shell_proxy_->IsConnected();});
ASSERT_TRUE(shell_proxy_->IsConnected());
EnableInteractiveShutdown(true);
@@ -277,6 +289,7 @@ struct TestGnomeSessionManager : testing::Test
logind_.reset();
console_kit_.reset();
session_manager_.reset();
+ display_manager_seat_.reset();
}
bool SettingsAvailable()
@@ -342,6 +355,7 @@ struct TestGnomeSessionManager : testing::Test
static DBusServer::Ptr console_kit_;
static DBusServer::Ptr logind_;
static DBusServer::Ptr session_manager_;
+ static DBusServer::Ptr display_manager_seat_;
static DBusProxy::Ptr shell_proxy_;
};
@@ -350,6 +364,7 @@ DBusServer::Ptr TestGnomeSessionManager::upower_;
DBusServer::Ptr TestGnomeSessionManager::console_kit_;
DBusServer::Ptr TestGnomeSessionManager::logind_;
DBusServer::Ptr TestGnomeSessionManager::session_manager_;
+DBusServer::Ptr TestGnomeSessionManager::display_manager_seat_;
DBusProxy::Ptr TestGnomeSessionManager::shell_proxy_;
bool TestGnomeSessionManager::can_shutdown_;
bool TestGnomeSessionManager::can_suspend_;
@@ -390,6 +405,23 @@ TEST_F(TestGnomeSessionManager, HostName)
EXPECT_EQ(manager->HostName(), g_get_host_name());
}
+TEST_F(TestGnomeSessionManager, SwitchToGreeter)
+{
+ bool switch_called = false;
+
+ display_manager_seat_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) {
+ if (method == "SwitchToGreeter")
+ switch_called = true;
+
+ return static_cast<GVariant*>(nullptr);
+ });
+
+ manager->SwitchToGreeter();
+
+ Utils::WaitUntilMSec(switch_called);
+ EXPECT_TRUE(switch_called);
+}
+
TEST_F(TestGnomeSessionManager, ScreenSaverActivate)
{
bool signal_emitted = false;
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index fefc6d15e..eee05c0bf 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -61,7 +61,7 @@ const std::string DEVICES_URI = "unity://devices";
namespace app
{
const std::string UBUNTU_ONE = BUILDDIR "/tests/data/applications/ubuntuone-installer.desktop";
- const std::string SW_CENTER = BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop";
+ const std::string SW_CENTER = BUILDDIR "/tests/data/applications/org.gnome.Software.desktop";
const std::string UPDATE_MANAGER = BUILDDIR "/tests/data/applications/update-manager.desktop";
const std::string BZR_HANDLE_PATCH = BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop";
const std::string NO_ICON = BUILDDIR "/tests/data/applications/no-icon.desktop";
@@ -136,8 +136,10 @@ private:
struct MockApplicationLauncherIcon : ApplicationLauncherIcon
{
- typedef NiceMock<MockApplicationLauncherIcon> Nice;
- typedef nux::ObjectPtr<MockApplicationLauncherIcon::Nice> Ptr;
+ // NiceMock doesn't work well with Virtual Inheritance, so we need to disable it
+ //typedef NiceMock<MockApplicationLauncherIcon> Nice;
+ typedef MockApplicationLauncherIcon Nice;
+ typedef nux::ObjectPtr<MockApplicationLauncherIcon> Ptr;
typedef bool Fake;
MockApplicationLauncherIcon(Fake = true, std::string const& remote_uri = "")
@@ -154,7 +156,8 @@ struct MockApplicationLauncherIcon : ApplicationLauncherIcon
}
explicit MockApplicationLauncherIcon(ApplicationPtr const& app)
- : ApplicationLauncherIcon(app)
+ : WindowedLauncherIcon(IconType::APPLICATION)
+ , ApplicationLauncherIcon(app)
{
ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); }));
ON_CALL(*this, UnStick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::UnStick(); }));
@@ -170,15 +173,18 @@ struct MockApplicationLauncherIcon : ApplicationLauncherIcon
MOCK_CONST_METHOD0(GetRemoteUri, std::string());
MOCK_METHOD1(Stick, void(bool));
MOCK_METHOD0(UnStick, void());
- MOCK_METHOD0(Quit, void());
+ MOCK_CONST_METHOD0(Quit, void());
};
struct MockVolumeLauncherIcon : public VolumeLauncherIcon
{
typedef nux::ObjectPtr<MockVolumeLauncherIcon> Ptr;
+ // typedef NiceMock<MockVolumeLauncherIcon> Nice;
+ typedef MockVolumeLauncherIcon Nice;
MockVolumeLauncherIcon()
- : VolumeLauncherIcon(Volume::Ptr(volume_ = new NiceMock<MockVolume>()),
+ : WindowedLauncherIcon(IconType::DEVICE)
+ , VolumeLauncherIcon(Volume::Ptr(volume_ = new NiceMock<MockVolume>()),
std::make_shared<MockDevicesSettings::Nice>(),
std::make_shared<MockDeviceNotificationDisplay::Nice>(),
std::make_shared<MockFileManager::Nice>())
@@ -269,7 +275,7 @@ protected:
void DisconnectSignals()
{
ApplicationManager::Default().application_started.clear();
- Impl()->device_section_.icon_added.clear();
+ Impl()->device_section_->icon_added.clear();
Impl()->model_->icon_removed.clear();
Impl()->model_->saved.clear();
Impl()->model_->order_changed.clear();
@@ -640,8 +646,8 @@ TEST_F(TestLauncherController, CreateFavoriteInvalidDesktopFile)
TEST_F(TestLauncherController, CreateFavoriteDevice)
{
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon = icons.front();
ASSERT_TRUE(device_icon.IsValid());
@@ -903,8 +909,8 @@ TEST_F(TestLauncherController, AddDevices)
{
lc.ClearModel();
lc.DisconnectSignals();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon1 = icons.front();
auto const& device_icon2 = *(std::next(icons.begin()));
@@ -949,7 +955,7 @@ TEST_F(TestLauncherController, MigrateFavoritesUnneeded)
TEST_F(TestLauncherController, SetupIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
lc.Impl()->expo_icon_->UnStick();
lc.Impl()->desktop_icon_->UnStick();
auto const& model = lc.Impl()->model_;
@@ -970,7 +976,7 @@ TEST_F(TestLauncherController, SetupIcons)
fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER);
EXPECT_EQ(model->IconIndex(fav), ++icon_index);
- for (auto const& device : lc.Impl()->device_section_.GetIcons())
+ for (auto const& device : lc.Impl()->device_section_->GetIcons())
ASSERT_EQ(model->IconIndex(device), ++icon_index);
fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER);
@@ -995,7 +1001,7 @@ TEST_F(TestLauncherController, SetupIcons)
TEST_F(TestLauncherController, ResetIconPriorities)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
auto const& model = lc.Impl()->model_;
favorite_store.AddFavorite(places::APPS_URI, -1);
@@ -1012,7 +1018,7 @@ TEST_F(TestLauncherController, ResetIconPriorities)
int icon_index = -1;
- for (auto const& device : lc.Impl()->device_section_.GetIcons())
+ for (auto const& device : lc.Impl()->device_section_->GetIcons())
ASSERT_EQ(model->IconIndex(device), ++icon_index);
auto fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER);
@@ -1043,8 +1049,8 @@ TEST_F(TestLauncherController, ResetIconPriorities)
TEST_F(TestLauncherController, GetLastIconPriorityUnSticky)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& last_device = device_icons.back();
favorite_store.SetFavorites({ places::DEVICES_URI,
@@ -1060,8 +1066,8 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnSticky)
TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithAllStickyIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& last_device = device_icons.back();
favorite_store.SetFavorites({ places::DEVICES_URI,
@@ -1080,8 +1086,8 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithAllStickyIcons)
TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithSomeStickyIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& first_device = *(std::next(device_icons.rbegin()));
auto const& last_device = device_icons.back();
@@ -1100,7 +1106,7 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithSomeStickyIcons)
TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(0);
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0);
lc.Impl()->SetupIcons();
lc.DisconnectSignals();
@@ -1111,7 +1117,7 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIcons)
TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIconsAndUri)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(0);
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0);
favorite_store.SetFavorites({ places::DEVICES_URI,
FavoriteStore::URI_PREFIX_APP + app::SW_CENTER });
@@ -1136,11 +1142,11 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIconsAndUri)
TEST_F(TestLauncherController, GetLastIconPrioritySticky)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
lc.Impl()->SetupIcons();
lc.DisconnectSignals();
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& first_device = device_icons.front();
int last_priority = lc.Impl()->GetLastIconPriority<VolumeLauncherIcon>("", true);
@@ -1150,8 +1156,8 @@ TEST_F(TestLauncherController, GetLastIconPrioritySticky)
TEST_F(TestLauncherController, GetLastIconPriorityStickyWithAllStickyIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& last_device = device_icons.back();
favorite_store.SetFavorites({ places::DEVICES_URI,
@@ -1170,8 +1176,8 @@ TEST_F(TestLauncherController, GetLastIconPriorityStickyWithAllStickyIcons)
TEST_F(TestLauncherController, GetLastIconPriorityStickyWithSomeStickyIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(3);
- auto const& device_icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3);
+ auto const& device_icons = lc.Impl()->device_section_->GetIcons();
auto const& first_device = *(std::next(device_icons.rbegin()));
favorite_store.SetFavorites({ places::DEVICES_URI,
@@ -1189,7 +1195,7 @@ TEST_F(TestLauncherController, GetLastIconPriorityStickyWithSomeStickyIcons)
TEST_F(TestLauncherController, GetLastIconPriorityStickyWithNoIcons)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection(0);
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0);
lc.Impl()->SetupIcons();
lc.DisconnectSignals();
@@ -1240,8 +1246,8 @@ TEST_F(TestLauncherController, LauncherAddRequestApplicationStick)
TEST_F(TestLauncherController, LauncherAddRequestDeviceAdd)
{
auto const& model = lc.Impl()->model_;
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon = icons.front();
auto const& icon_uri = device_icon->RemoteUri();
@@ -1262,7 +1268,7 @@ TEST_F(TestLauncherController, LauncherAddRequestDeviceAdd)
TEST_F(TestLauncherController, LauncherAddRequestDeviceStick)
{
auto const& model = lc.Impl()->model_;
- MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice());
lc.Impl()->RegisterIcon(device_icon, std::numeric_limits<int>::max());
auto app_icons = model->GetSublist<ApplicationLauncherIcon>();
@@ -1287,7 +1293,7 @@ TEST_F(TestLauncherController, LauncherRemoveRequestApplicationUnStickAndQuit)
TEST_F(TestLauncherController, LauncherRemoveRequestDeviceEjects)
{
- MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice());
EXPECT_CALL(*(device_icon->volume_), CanBeEjected())
.WillRepeatedly(Return(true));
@@ -1302,7 +1308,7 @@ TEST_F(TestLauncherController, LauncherRemoveRequestDeviceEjects)
TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops)
{
- MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice());
EXPECT_CALL(*(device_icon->volume_), CanBeEjected())
.WillRepeatedly(Return(false));
@@ -1315,38 +1321,6 @@ TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops)
lc.launcher().remove_request.emit(device_icon);
}
-TEST_F(TestLauncherController, LauncherAddRequestSpecial)
-{
- std::string desktop = app::BZR_HANDLE_PATCH;
- std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop;
- ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid());
- EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0);
-
- lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32);
-
- auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri);
- ASSERT_TRUE(sw_center_icon.IsValid());
- EXPECT_TRUE(sw_center_icon->IsSticky());
- EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr);
-}
-
-TEST_F(TestLauncherController, LauncherAddRequestSpecialIgnored)
-{
- std::string desktop = app::BZR_HANDLE_PATCH;
- std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop;
-
- MockApplicationLauncherIcon::Ptr bamf_icon(new MockApplicationLauncherIcon::Nice(desktop));
- lc.Impl()->RegisterIcon(bamf_icon, std::numeric_limits<int>::max());
- ASSERT_TRUE(lc.Impl()->GetIconByUri(icon_uri).IsValid());
-
- EXPECT_CALL(*bamf_icon, Stick(false)).Times(0);
-
- int previous_model_size = lc.Impl()->model_->Size();
- lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32);
-
- EXPECT_EQ(previous_model_size, lc.Impl()->model_->Size());
-}
-
TEST_F(TestLauncherController, SaveIconsOrder)
{
favorite_store.ClearFavorites();
@@ -1362,7 +1336,7 @@ TEST_F(TestLauncherController, SaveIconsOrder)
invisible_app->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
lc.Impl()->RegisterIcon(invisible_app, ++priority);
- MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice());
sticky_device->Stick(false);
lc.Impl()->RegisterIcon(sticky_device, ++priority);
@@ -1393,7 +1367,7 @@ TEST_F(TestLauncherController, SaveIconsOrderWithOnlyStickyIcons)
sticky_app->Stick(false);
lc.Impl()->RegisterIcon(sticky_app, ++priority);
- MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice());
sticky_device->Stick(false);
lc.Impl()->RegisterIcon(sticky_device, ++priority);
@@ -1422,7 +1396,7 @@ TEST_F(TestLauncherController, SaveIconsOrderTriesToKeepIconProvidersOrder)
sticky_app->Stick(false);
lc.Impl()->RegisterIcon(sticky_app, ++priority);
- MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice());
sticky_device->Stick(false);
lc.Impl()->RegisterIcon(sticky_device, ++priority);
@@ -1447,7 +1421,7 @@ TEST_F(TestLauncherController, SaveIconsOrderTriesToKeepIconProvidersOrder2)
sticky_app->Stick(false);
lc.Impl()->RegisterIcon(sticky_app, ++priority);
- MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>());
+ MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice());
sticky_device->Stick(false);
lc.Impl()->RegisterIcon(sticky_device, ++priority);
@@ -1597,9 +1571,9 @@ TEST_F(TestLauncherController, OnFavoriteStoreFavoriteAddedStickAfter)
TEST_F(TestLauncherController, OnFavoriteStoreFavoriteAddedDeviceSection)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
auto const& model = lc.Impl()->model_;
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon1(icons.front());
auto const& device_icon2(*(std::next(icons.begin())));
@@ -1634,10 +1608,10 @@ TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedApplication)
TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDevice)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
auto const& model = lc.Impl()->model_;
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon(icons.front());
favorite_store.SetFavorites({ lc.Impl()->expo_icon_->RemoteUri(),
@@ -1660,10 +1634,10 @@ TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDevice)
TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDeviceSection)
{
lc.ClearModel();
- lc.Impl()->device_section_ = MockDeviceLauncherSection();
+ lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>();
auto const& model = lc.Impl()->model_;
- auto const& icons = lc.Impl()->device_section_.GetIcons();
+ auto const& icons = lc.Impl()->device_section_->GetIcons();
auto const& device_icon1(icons.front());
auto const& device_icon2(*(std::next(icons.begin())));
@@ -1958,10 +1932,9 @@ TEST_F(TestLauncherController, IconShowsOnQuickApplicationReopen)
unity::glib::Object<BamfMockApplication> bamf_mock_application(bamf_mock_application_new());
ApplicationPtr app(new unity::bamf::Application(mock_manager, unity::glib::object_cast<BamfApplication>(bamf_mock_application)));
- MockApplicationLauncherIcon::Ptr our_icon;
-
+ AbstractLauncherIcon::Ptr our_icon;
mock_manager.Default().application_started.emit(app);
-
+
app->title.changed.emit("Hello");
auto app_icons = lc.Impl()->model_->GetSublist<ApplicationLauncherIcon>();
@@ -1971,7 +1944,7 @@ TEST_F(TestLauncherController, IconShowsOnQuickApplicationReopen)
{
our_icon = icon;
break;
- }
+ }
}
ASSERT_TRUE(our_icon);
EXPECT_FALSE(our_icon->removed);
diff --git a/tests/test_lockscreen_controller.cpp b/tests/test_lockscreen_controller.cpp
index d77f0a298..3fcdf520b 100644
--- a/tests/test_lockscreen_controller.cpp
+++ b/tests/test_lockscreen_controller.cpp
@@ -20,7 +20,7 @@
#include <gmock/gmock.h>
using namespace testing;
-#include "lockscreen/UserPromptView.h"
+#include "lockscreen/LockScreenAbstractPromptView.h"
#include "lockscreen/LockScreenController.h"
#include <Nux/NuxTimerTickSource.h>
@@ -51,26 +51,27 @@ const unsigned TICK_DURATION = 10 * 1000;
}
-struct MockShield : AbstractShield
+struct MockShield : BaseShield
{
MockShield()
- : AbstractShield(nullptr, nullptr, nullptr, nux::ObjectPtr<UserPromptView>(), 0, false)
+ : BaseShield(nullptr, nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false)
{}
MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
MOCK_METHOD0(ActivatePanel, void());
MOCK_CONST_METHOD0(HasGrab, bool());
+ MOCK_METHOD0(ShowPrimaryView, void());
};
struct ShieldFactoryMock : ShieldFactoryInterface
{
- nux::ObjectPtr<AbstractShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
- Accelerators::Ptr const&,
- nux::ObjectPtr<UserPromptView> const&,
- int, bool) override
+ nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
+ indicator::Indicators::Ptr const&,
+ Accelerators::Ptr const&,
+ nux::ObjectPtr<AbstractUserPromptView> const&,
+ int, bool) override
{
- return nux::ObjectPtr<AbstractShield>(new MockShield());
+ return nux::ObjectPtr<BaseShield>(new MockShield());
}
};
diff --git a/tests/test_mock_devices.h b/tests/test_mock_devices.h
index 2f4218fc5..d429b569b 100644
--- a/tests/test_mock_devices.h
+++ b/tests/test_mock_devices.h
@@ -78,11 +78,13 @@ struct MockVolume : Volume
typedef std::shared_ptr<MockVolume> Ptr;
typedef testing::NiceMock<MockVolume> Nice;
+ MOCK_CONST_METHOD0(CanBeFormatted, bool(void));
MOCK_CONST_METHOD0(CanBeRemoved, bool(void));
MOCK_CONST_METHOD0(CanBeStopped, bool(void));
MOCK_CONST_METHOD0(GetName, std::string(void));
MOCK_CONST_METHOD0(GetIconName, std::string(void));
MOCK_CONST_METHOD0(GetIdentifier, std::string(void));
+ MOCK_CONST_METHOD0(GetUnixDevicePath, std::string(void));
MOCK_CONST_METHOD0(GetUri, std::string(void));
MOCK_CONST_METHOD0(HasSiblings, bool(void));
MOCK_CONST_METHOD0(CanBeEjected, bool(void));
diff --git a/tests/test_mock_filemanager.h b/tests/test_mock_filemanager.h
index 231c0074e..1e541ebfd 100644
--- a/tests/test_mock_filemanager.h
+++ b/tests/test_mock_filemanager.h
@@ -32,15 +32,18 @@ struct MockFileManager : FileManager
typedef testing::NiceMock<MockFileManager> Nice;
MOCK_METHOD2(Open, void(std::string const& uri, uint64_t time));
- MOCK_METHOD2(OpenActiveChild, void(std::string const& uri, uint64_t time));
MOCK_METHOD1(OpenTrash, void(uint64_t time));
MOCK_METHOD1(TrashFile, bool(std::string const& uri));
MOCK_METHOD1(EmptyTrash, void(uint64_t time));
MOCK_METHOD3(CopyFiles, void(std::set<std::string> const& files, std::string const& dest, uint64_t time));
- MOCK_CONST_METHOD0(OpenedLocations, std::vector<std::string>());
- MOCK_CONST_METHOD1(IsPrefixOpened, bool(std::string const& uri));
- MOCK_CONST_METHOD0(IsTrashOpened, bool());
- MOCK_CONST_METHOD0(IsDeviceOpened, bool());
+ MOCK_CONST_METHOD1(WindowsForLocation, WindowList(std::string const&));
+ MOCK_CONST_METHOD1(LocationForWindow, std::string(ApplicationWindowPtr const&));
+
+ MockFileManager()
+ {
+ using namespace testing;
+ ON_CALL(*this, WindowsForLocation(_)).WillByDefault(Return(WindowList()));
+ }
};
}
diff --git a/tests/test_mock_session_manager.h b/tests/test_mock_session_manager.h
index 7d672b0e3..7e5ebeb16 100644
--- a/tests/test_mock_session_manager.h
+++ b/tests/test_mock_session_manager.h
@@ -28,10 +28,12 @@ namespace session
struct MockManager : Manager
{
typedef std::shared_ptr<MockManager> Ptr;
+ typedef std::function<void(std::string const&)> ReplyCallback;
MOCK_CONST_METHOD0(RealName, std::string());
MOCK_CONST_METHOD0(UserName, std::string());
MOCK_CONST_METHOD0(HostName, std::string());
+ MOCK_CONST_METHOD1(UserIconFile, void(ReplyCallback const&));
MOCK_METHOD0(ScreenSaverActivate, void());
MOCK_METHOD0(ScreenSaverDeactivate, void());
@@ -43,6 +45,7 @@ struct MockManager : Manager
MOCK_METHOD0(Suspend, void());
MOCK_METHOD0(Hibernate, void());
MOCK_METHOD0(CancelAction, void());
+ MOCK_METHOD0(SwitchToGreeter, void());
MOCK_CONST_METHOD0(CanLock, bool());
MOCK_CONST_METHOD0(CanShutdown, bool());
diff --git a/tests/test_previews_application.cpp b/tests/test_previews_application.cpp
index 8a268869e..d5a893d84 100644
--- a/tests/test_previews_application.cpp
+++ b/tests/test_previews_application.cpp
@@ -72,7 +72,7 @@ public:
GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99"));
- unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
+ unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string(TESTDATADIR "/bfb.png", NULL));
unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "License & special char");
unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Copywrite & special char");
unity_protocol_application_preview_set_last_update(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "11th Apr 2012");
diff --git a/tests/test_software_center_launcher_icon.cpp b/tests/test_software_center_launcher_icon.cpp
index abf65d09f..98ef81d4d 100644
--- a/tests/test_software_center_launcher_icon.cpp
+++ b/tests/test_software_center_launcher_icon.cpp
@@ -42,36 +42,34 @@ namespace launcher
{
namespace
{
-const std::string PRE_INSTALL_ICON = "sw-center-launcher-icon";
-const std::string FINAL_ICON = "softwarecenter";
-const std::string APP_NAME = "Ubuntu Software Center";
+const std::string FINAL_ICON = "org.gnome.Software";
+const std::string APP_NAME = "Software";
const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data";
-const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop";
-const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop";
+const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop";
+const std::string GS_APP_INSTALL_DESKTOP = "org.gnome.Software.desktop";
}
struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase
{
TestSoftwareCenterLauncherIcon()
- : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME))
- , icon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)
+ : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME))
+ , icon(gs, "/com/canonical/unity/test/object/path")
{}
struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon
{
MockSoftwareCenterLauncherIcon(ApplicationPtr const& app,
- std::string const& aptdaemon_trans_id,
- std::string const& icon_path)
- : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)
+ std::string const& aptdaemon_trans_id)
+ : WindowedLauncherIcon(IconType::APPLICATION)
+ , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id)
{}
void LauncherIconUnstick() { LauncherIcon::UnStick(); }
using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
- using SoftwareCenterLauncherIcon::GetRemoteUri;
using SoftwareCenterLauncherIcon::OnFinished;
using SoftwareCenterLauncherIcon::OnPropertyChanged;
- using SoftwareCenterLauncherIcon::drag_window_;
+ using LauncherIcon::GetRemoteUri;
};
nux::ObjectPtr<Launcher> CreateLauncher()
@@ -85,7 +83,7 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase
panel::Style panel;
nux::ObjectPtr<MockableBaseWindow> launcher_win;
- MockApplication::Ptr usc;
+ MockApplication::Ptr gs;
MockSoftwareCenterLauncherIcon icon;
};
@@ -93,75 +91,54 @@ TEST_F(TestSoftwareCenterLauncherIcon, Construction)
{
EXPECT_FALSE(icon.IsVisible());
EXPECT_TRUE(icon.IsSticky());
- EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position());
EXPECT_EQ("Waiting to install", icon.tooltip_text());
- EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
}
TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial)
{
// no transformation needed
- usc->desktop_file_ = USC_DESKTOP;
- EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP);
+ gs->desktop_file_ = GS_DESKTOP;
+ EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP);
}
-TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall)
-{
- // ensure that tranformation from app-install data desktop files works
- usc->desktop_file_ = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop";
- EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(),
- LOCAL_DATA_DIR+"/applications/kde4/afile.desktop");
-}
-
-TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent)
-{
- // now simualte data coming from the sc-agent
- usc->desktop_file_ = "/tmp/software-center-agent:VP2W9M:ubuntu-software-center.desktop";
- EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP);
-}
-
-// simulate a OnFinished signal from a /usr/share/app-install location
-// and ensure that the remote uri is updated from temp location to
-// the real location
TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile)
{
icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
-
- EXPECT_EQ(USC_DESKTOP, icon.DesktopFile());
+ EXPECT_EQ(GS_DESKTOP, icon.DesktopFile());
}
TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesRemoteURI)
{
icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
- ASSERT_EQ(USC_DESKTOP, icon.DesktopFile());
- EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + USC_DESKTOP, icon.GetRemoteUri());
+ ASSERT_EQ(GS_DESKTOP, icon.DesktopFile());
+ EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + GS_DESKTOP, icon.GetRemoteUri());
}
TEST_F(TestSoftwareCenterLauncherIcon, DisconnectsOldAppSignals)
{
- ASSERT_FALSE(usc->closed.empty());
+ ASSERT_FALSE(gs->closed.empty());
icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
- EXPECT_TRUE(usc->closed.empty());
- EXPECT_TRUE(usc->window_opened.empty());
- EXPECT_TRUE(usc->window_moved.empty());
- EXPECT_TRUE(usc->window_closed.empty());
- EXPECT_TRUE(usc->visible.changed.empty());
- EXPECT_TRUE(usc->active.changed.empty());
- EXPECT_TRUE(usc->running.changed.empty());
- EXPECT_TRUE(usc->urgent.changed.empty());
- EXPECT_TRUE(usc->desktop_file.changed.empty());
- EXPECT_TRUE(usc->title.changed.empty());
- EXPECT_TRUE(usc->icon.changed.empty());
+ EXPECT_TRUE(gs->closed.empty());
+ EXPECT_TRUE(gs->window_opened.empty());
+ EXPECT_TRUE(gs->window_moved.empty());
+ EXPECT_TRUE(gs->window_closed.empty());
+ EXPECT_TRUE(gs->visible.changed.empty());
+ EXPECT_TRUE(gs->active.changed.empty());
+ EXPECT_TRUE(gs->running.changed.empty());
+ EXPECT_TRUE(gs->urgent.changed.empty());
+ EXPECT_TRUE(gs->desktop_file.changed.empty());
+ EXPECT_TRUE(gs->title.changed.empty());
+ EXPECT_TRUE(gs->icon.changed.empty());
}
TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedRemoveInvalidNewAppIcon)
{
// Using an icon ptr, to get the removed signal to be properly emitted
nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr(
- new MockSoftwareCenterLauncherIcon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON));
+ new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path"));
bool removed = false;
auto& app_manager = unity::ApplicationManager::Default();
@@ -200,7 +177,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedKeepsStickyStatus)
icon.LauncherIconUnstick();
bool saved = false;
- usc->sticky = true;
+ gs->sticky = true;
icon.position_saved.connect([&saved] {saved = true;});
ASSERT_FALSE(icon.IsSticky());
@@ -213,14 +190,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesTooltip)
{
icon.tooltip_text = "FooText";
icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
- EXPECT_EQ(icon.tooltip_text(), usc->title());
-}
-
-TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon)
-{
- icon.icon_name = "foo-icon";
- icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
- EXPECT_EQ(icon.icon_name(), usc->icon());
+ EXPECT_EQ(icon.tooltip_text(), gs->title());
}
TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent)
@@ -229,52 +199,9 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent)
icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
}
-TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition)
-{
- EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2));
- EXPECT_FALSE(icon.IsVisible());
- EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
-}
-
-TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition)
-{
- EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0));
- EXPECT_TRUE(icon.IsVisible());
- EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
-}
-
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
-struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {};
-INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1));
-
-TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate)
-{
- auto launcher = CreateLauncher();
- launcher->monitor = GetParam();
- icon.SetCenter({1, 1, 0}, launcher->monitor());
- ASSERT_TRUE(icon.Animate(launcher, 2, 2));
- EXPECT_FALSE(icon.IsVisible());
- EXPECT_TRUE(icon.icon_name().empty());
-
- for (unsigned i = 0; i < monitors::MAX; ++i)
- ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i));
-
- bool animated = false;
- ASSERT_TRUE(icon.drag_window_);
- icon.drag_window_->anim_completed.connect([&animated] { animated = true; });
- Utils::WaitUntilMSec(animated);
- ASSERT_TRUE(animated);
-
- EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
- EXPECT_FALSE(icon.drag_window_);
-
- for (unsigned i = 0; i < monitors::MAX; ++i)
- ASSERT_TRUE(icon.IsVisibleOnMonitor(i));
-
- EXPECT_TRUE(icon.IsVisible());
-}
struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {};
INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10));
diff --git a/tests/test_switcher_controller.h b/tests/test_switcher_controller.h
index bc0118df4..5e35b2e59 100644
--- a/tests/test_switcher_controller.h
+++ b/tests/test_switcher_controller.h
@@ -27,10 +27,11 @@
#include "test_utils.h"
#include "DesktopLauncherIcon.h"
-#include "SimpleLauncherIcon.h"
+#include "WindowedLauncherIcon.h"
#include "SwitcherController.h"
#include "SwitcherView.h"
#include "TimeUtil.h"
+#include "mock-application.h"
#include "mock-base-window.h"
#include "test_standalone_wm.h"
@@ -48,35 +49,24 @@ const unsigned TICK_DURATION = 10 * 1000;
/**
* A fake ApplicationWindow for verifying selection of the switcher.
*/
-class FakeApplicationWindow : public unity::ApplicationWindow
+struct FakeApplicationWindow : public ::testmocks::MockApplicationWindow::Nice
{
-public:
+ typedef NiceMock<FakeApplicationWindow> Nice;
FakeApplicationWindow(Window xid, uint64_t active_number = 0);
~FakeApplicationWindow();
-
- virtual WindowType type() const;
-
- virtual Window window_id() const;
- virtual int monitor() const;
- virtual unity::ApplicationPtr application() const;
- virtual bool Focus() const;
- virtual void Quit() const;
-
-private:
- Window xid_;
};
/**
* A fake LauncherIcon for verifying selection operations of the switcher.
*/
-struct FakeLauncherIcon : unity::launcher::SimpleLauncherIcon
+struct FakeLauncherIcon : unity::launcher::WindowedLauncherIcon
{
FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority);
- unity::WindowList Windows() override;
bool AllowDetailViewInSwitcher() const override;
bool ShowInSwitcher(bool) override;
uint64_t SwitcherPriority() override;
+ WindowList GetManagedWindows() const override;
bool allow_detail_view_;
uint64_t priority_;
diff --git a/tests/test_switcher_controller_class.cpp b/tests/test_switcher_controller_class.cpp
index 749359f54..807a239bc 100644
--- a/tests/test_switcher_controller_class.cpp
+++ b/tests/test_switcher_controller_class.cpp
@@ -26,14 +26,13 @@ using namespace unity::switcher;
using namespace std::chrono;
FakeApplicationWindow::FakeApplicationWindow(Window xid, uint64_t active_number)
- : xid_(xid)
+ : MockApplicationWindow::Nice(xid)
{
- auto standalone_window = std::make_shared<StandaloneWindow>(xid_);
+ SetMonitor(-1);
+ auto standalone_window = std::make_shared<StandaloneWindow>(window_id());
standalone_window->active_number = active_number;
testwrapper::StandaloneWM::Get()->AddStandaloneWindow(standalone_window);
-
- title.SetGetterFunction([this] { return "FakeApplicationWindow"; });
- icon.SetGetterFunction([this] { return ""; });
+ ON_CALL(*this, Quit()).WillByDefault(Invoke([this] { WindowManager::Default().Close(window_id()); }));
}
FakeApplicationWindow::~FakeApplicationWindow()
@@ -41,25 +40,17 @@ FakeApplicationWindow::~FakeApplicationWindow()
testwrapper::StandaloneWM::Get()->Close(xid_);
}
-WindowType FakeApplicationWindow::type() const { return WindowType::MOCK; }
-
-Window FakeApplicationWindow::window_id() const { return xid_; }
-int FakeApplicationWindow::monitor() const { return -1; }
-ApplicationPtr FakeApplicationWindow::application() const { return ApplicationPtr(); }
-bool FakeApplicationWindow::Focus() const { return false; }
-void FakeApplicationWindow::Quit() const { WindowManager::Default().Close(xid_); }
-
FakeLauncherIcon::FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority)
- : launcher::SimpleLauncherIcon(IconType::APPLICATION)
+ : launcher::WindowedLauncherIcon(IconType::APPLICATION)
, allow_detail_view_(allow_detail_view)
, priority_(priority)
- , window_list{ std::make_shared<FakeApplicationWindow>(priority_ | 0x0001, SwitcherPriority()),
- std::make_shared<FakeApplicationWindow>(priority_ | 0x0002, priority_) }
+ , window_list{ std::make_shared<FakeApplicationWindow::Nice>(priority_ | 0x0001, SwitcherPriority()),
+ std::make_shared<FakeApplicationWindow::Nice>(priority_ | 0x0002, priority_) }
{
tooltip_text = app_name;
}
-WindowList FakeLauncherIcon::Windows()
+WindowList FakeLauncherIcon::GetManagedWindows() const
{
return window_list;
}
@@ -85,7 +76,7 @@ uint64_t FakeLauncherIcon::SwitcherPriority()
//class TestSwitcherController : public testing::Test
TestSwitcherController::TestSwitcherController()
: animation_controller_(tick_source_)
- , mock_window_(new NiceMock<testmocks::MockBaseWindow>())
+ , mock_window_(new NiceMock<unity::testmocks::MockBaseWindow>())
, controller_(std::make_shared<Controller>([this] { return mock_window_; }))
{
controller_->timeout_length = 0;
diff --git a/tests/test_trash_launcher_icon.cpp b/tests/test_trash_launcher_icon.cpp
index 839c70ff4..d8a5b6162 100644
--- a/tests/test_trash_launcher_icon.cpp
+++ b/tests/test_trash_launcher_icon.cpp
@@ -27,9 +27,11 @@
using namespace unity;
using namespace unity::launcher;
using namespace testing;
+using namespace testmocks;
namespace
{
+const std::string TRASH_URI = "trash:";
struct TestTrashLauncherIcon : testmocks::TestUnityAppBase
{
@@ -42,6 +44,12 @@ struct TestTrashLauncherIcon : testmocks::TestUnityAppBase
TrashLauncherIcon icon;
};
+TEST_F(TestTrashLauncherIcon, InitState)
+{
+ EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
+ EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+}
+
TEST_F(TestTrashLauncherIcon, Position)
{
EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::END);
@@ -74,15 +82,77 @@ TEST_F(TestTrashLauncherIcon, QuicklistEmptyTrash)
TEST_F(TestTrashLauncherIcon, RunningState)
{
- EXPECT_CALL(*fm_, IsTrashOpened()).WillRepeatedly(Return(true));
+ auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win1, win2})));
fm_->locations_changed.emit();
EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
- EXPECT_CALL(*fm_, IsTrashOpened()).WillRepeatedly(Return(false));
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList()));
fm_->locations_changed.emit();
EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
}
+TEST_F(TestTrashLauncherIcon, ActiveState)
+{
+ auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win1, win2})));
+ fm_->locations_changed.emit();
+ ASSERT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+
+ win2->LocalFocus();
+ EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList()));
+ fm_->locations_changed.emit();
+ EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+}
+
+TEST_F(TestTrashLauncherIcon, WindowsCount)
+{
+ WindowList windows((g_random_int() % 10) + 5);
+ for (unsigned i = 0; i < windows.capacity(); ++i)
+ windows[i] = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(windows));
+ fm_->locations_changed.emit();
+ EXPECT_EQ(icon.Windows().size(), windows.size());
+}
+
+TEST_F(TestTrashLauncherIcon, WindowsPerMonitor)
+{
+ WindowList windows((g_random_int() % 10) + 5);
+ for (unsigned i = 0; i < windows.capacity(); ++i)
+ {
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ win->monitor_ = i % 2;
+ windows[i] = win;
+ }
+
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(windows));
+ fm_->locations_changed.emit();
+
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), (windows.size() / 2) + (windows.size() % 2));
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), windows.size() / 2);
+}
+
+TEST_F(TestTrashLauncherIcon, WindowsOnMonitorChanges)
+{
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win})));
+ fm_->locations_changed.emit();
+
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 1);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 0);
+
+ win->SetMonitor(1);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 0);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 1);
+}
+
TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection)
{
auto file_manager = std::make_shared<NiceMock<MockFileManager>>();
diff --git a/tests/test_unity_settings.cpp b/tests/test_unity_settings.cpp
index 0bf07858f..f64c9c594 100644
--- a/tests/test_unity_settings.cpp
+++ b/tests/test_unity_settings.cpp
@@ -53,12 +53,14 @@ struct TestUnitySettings : testing::Test
, sig_receiver(unity_settings)
{
g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP));
+ g_settings_set_enum(gsettings, "desktop-type", static_cast<int>(unity::DesktopType::UBUNTU));
}
~TestUnitySettings()
{
sig_receiver.notify_callbacks();
g_settings_reset(gsettings, "form-factor");
+ g_settings_reset(gsettings, "desktop-type");
}
};
@@ -78,6 +80,14 @@ TEST_F(TestUnitySettings, GetFormFactor)
EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK);
}
+TEST_F(TestUnitySettings, GetDesktopType)
+{
+ ASSERT_NE(unity_settings->desktop_type(), unity::DesktopType::UBUNTUKYLIN);
+
+ g_settings_set_enum(gsettings, "desktop-type", static_cast<int>(unity::DesktopType::UBUNTUKYLIN));
+ EXPECT_EQ(unity_settings->desktop_type(), unity::DesktopType::UBUNTUKYLIN);
+}
+
TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern)
{
EXPECT_CALL(sig_receiver, FormFactorChanged(unity::FormFactor::NETBOOK));
diff --git a/tests/test_volume_launcher_icon.cpp b/tests/test_volume_launcher_icon.cpp
index 8d6bc48c2..1bd4f5a56 100644
--- a/tests/test_volume_launcher_icon.cpp
+++ b/tests/test_volume_launcher_icon.cpp
@@ -27,8 +27,11 @@ using namespace testing;
#include "test_utils.h"
#include "test_mock_devices.h"
#include "test_mock_filemanager.h"
+#include "mock-application.h"
+
using namespace unity;
using namespace unity::launcher;
+using namespace testmocks;
namespace
{
@@ -43,7 +46,7 @@ struct TestVolumeLauncherIcon : public Test
{
SetupVolumeDefaultBehavior();
SetupSettingsDefaultBehavior();
- icon_ = new NiceMock<VolumeLauncherIcon>(volume_, settings_, notifications_, file_manager_);
+ icon_ = new VolumeLauncherIcon(volume_, settings_, notifications_, file_manager_);
}
void SetupSettingsDefaultBehavior()
@@ -53,11 +56,13 @@ struct TestVolumeLauncherIcon : public Test
void SetupVolumeDefaultBehavior()
{
+ ON_CALL(*volume_, CanBeFormatted()).WillByDefault(Return(false));
ON_CALL(*volume_, CanBeRemoved()).WillByDefault(Return(false));
ON_CALL(*volume_, CanBeStopped()).WillByDefault(Return(false));
ON_CALL(*volume_, GetName()).WillByDefault(Return("Test Name"));
ON_CALL(*volume_, GetIconName()).WillByDefault(Return("Test Icon Name"));
ON_CALL(*volume_, GetIdentifier()).WillByDefault(Return("Test Identifier"));
+ ON_CALL(*volume_, GetUnixDevicePath()).WillByDefault(Return("/dev/sda1"));
ON_CALL(*volume_, GetUri()).WillByDefault(Return("file:///media/user/device_uri"));
ON_CALL(*volume_, HasSiblings()).WillByDefault(Return(false));
ON_CALL(*volume_, CanBeEjected()).WillByDefault(Return(false));
@@ -94,7 +99,7 @@ struct TestVolumeLauncherIconDelayedConstruction : TestVolumeLauncherIcon
void CreateIcon()
{
- icon_ = new NiceMock<VolumeLauncherIcon>(volume_, settings_, notifications_, file_manager_);
+ icon_ = new VolumeLauncherIcon(volume_, settings_, notifications_, file_manager_);
}
};
@@ -105,7 +110,7 @@ TEST_F(TestVolumeLauncherIcon, TestIconType)
TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnClosed)
{
- ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(false));
+ ON_CALL(*file_manager_, WindowsForLocation(_)).WillByDefault(Return(WindowList()));
CreateIcon();
EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
@@ -113,7 +118,8 @@ TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnClosed)
TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnOpened)
{
- ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(true));
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win})));
CreateIcon();
EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
@@ -128,16 +134,91 @@ TEST_F(TestVolumeLauncherIcon, FilemanagerSignalDisconnection)
TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedClosed)
{
- ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(false));
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList()));
file_manager_->locations_changed.emit();
EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
}
TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedOpened)
{
- ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(true));
+ auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2})));
+ file_manager_->locations_changed.emit();
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
+}
+
+TEST_F(TestVolumeLauncherIcon, RunningState)
+{
+ auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2})));
file_manager_->locations_changed.emit();
EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList()));
+ file_manager_->locations_changed.emit();
+ EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING));
+}
+
+TEST_F(TestVolumeLauncherIcon, ActiveState)
+{
+ auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2})));
+ file_manager_->locations_changed.emit();
+ ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+
+ win2->LocalFocus();
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList()));
+ file_manager_->locations_changed.emit();
+ EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+}
+
+TEST_F(TestVolumeLauncherIcon, WindowsCount)
+{
+ WindowList windows((g_random_int() % 10) + 5);
+ for (unsigned i = 0; i < windows.capacity(); ++i)
+ windows[i] = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(windows));
+ file_manager_->locations_changed.emit();
+ EXPECT_EQ(icon_->Windows().size(), windows.size());
+}
+
+TEST_F(TestVolumeLauncherIcon, WindowsPerMonitor)
+{
+ WindowList windows((g_random_int() % 10) + 5);
+ for (unsigned i = 0; i < windows.capacity(); ++i)
+ {
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ win->monitor_ = i % 2;
+ windows[i] = win;
+ }
+
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(windows));
+ file_manager_->locations_changed.emit();
+
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), (windows.size() / 2) + (windows.size() % 2));
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), windows.size() / 2);
+}
+
+TEST_F(TestVolumeLauncherIcon, WindowsOnMonitorChanges)
+{
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win})));
+ file_manager_->locations_changed.emit();
+
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 1);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 0);
+
+ win->SetMonitor(1);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 0);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 1);
}
TEST_F(TestVolumeLauncherIcon, TestPosition)
@@ -240,6 +321,32 @@ TEST_F(TestVolumeLauncherIconDelayedConstruction, TestVisibilityAfterUnmount_Bla
EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
}
+TEST_F(TestVolumeLauncherIcon, TestVisibilityWithWindows)
+{
+ ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(false));
+ settings_->changed.emit();
+ ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win})));
+ file_manager_->locations_changed.emit();
+
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+}
+
+TEST_F(TestVolumeLauncherIcon, TestVisibilityWithWindows_Blacklisted)
+{
+ ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true));
+ settings_->changed.emit();
+ ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win})));
+ file_manager_->locations_changed.emit();
+
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+}
+
TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_VolumeWithoutIdentifier)
{
EXPECT_CALL(*volume_, GetIdentifier())
@@ -251,22 +358,22 @@ TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_VolumeWithoutIdent
TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Success)
{
+ ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(false));
+ settings_->changed.emit();
+ ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
auto menuitem = GetMenuItemAtIndex(4);
ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Unlock from Launcher");
EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED));
- EXPECT_CALL(*settings_, TryToBlacklist(_))
- .Times(1);
-
- EXPECT_CALL(*settings_, IsABlacklistedDevice(_))
- .WillRepeatedly(Return(true));
-
+ EXPECT_CALL(*settings_, TryToBlacklist(volume_->GetIdentifier())).Times(1);
dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
+
+ EXPECT_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillRepeatedly(Return(true));
settings_->changed.emit(); // TryToBlacklist() works if DevicesSettings emits a changed signal.
- ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+ EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
}
TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Failure)
@@ -277,12 +384,49 @@ TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Failure)
EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED));
- EXPECT_CALL(*settings_, TryToBlacklist(_))
- .Times(1);
+ EXPECT_CALL(*settings_, TryToBlacklist(volume_->GetIdentifier())).Times(1);
+ dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
+
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+}
+
+TEST_F(TestVolumeLauncherIcon, TestLockToLauncherMenuItem_Success)
+{
+ ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true));
+ settings_->changed.emit();
+ ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+
+ auto menuitem = GetMenuItemAtIndex(4);
+ ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Lock to Launcher");
+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED));
+
+ EXPECT_CALL(*settings_, TryToUnblacklist(volume_->GetIdentifier())).Times(1);
dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
- ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+ EXPECT_CALL(*settings_, IsABlacklistedDevice(_)).WillRepeatedly(Return(false));
+ settings_->changed.emit(); // TryToBlacklist() works if DevicesSettings emits a changed signal.
+
+ EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+}
+
+TEST_F(TestVolumeLauncherIcon, TestLockToLauncherMenuItem_Failure)
+{
+ ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true));
+ settings_->changed.emit();
+ ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
+
+ auto menuitem = GetMenuItemAtIndex(4);
+
+ ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Lock to Launcher");
+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED));
+
+ EXPECT_CALL(*settings_, TryToUnblacklist(volume_->GetIdentifier())).Times(1);
+ dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
+
+ EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE));
}
TEST_F(TestVolumeLauncherIcon, TestOpenMenuItem)
@@ -298,7 +442,7 @@ TEST_F(TestVolumeLauncherIcon, TestOpenMenuItem)
InSequence seq;
EXPECT_CALL(*volume_, Mount());
- EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time));
+ EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time));
dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time);
}
@@ -318,7 +462,7 @@ TEST_F(TestVolumeLauncherIcon, TestNameMenuItem)
InSequence seq;
EXPECT_CALL(*volume_, Mount());
- EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time));
+ EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time));
dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time);
}
@@ -438,7 +582,7 @@ TEST_F(TestVolumeLauncherIcon, OnRemoved)
EXPECT_CALL(*settings_, TryToBlacklist(_))
.Times(0);
EXPECT_CALL(*settings_, TryToUnblacklist(_))
- .Times(0);
+ .Times(1);
volume_->removed.emit();
}
@@ -451,7 +595,7 @@ TEST_F(TestVolumeLauncherIcon, OnRemoved_RemovabledVolume)
EXPECT_CALL(*settings_, TryToBlacklist(_))
.Times(0);
EXPECT_CALL(*settings_, TryToUnblacklist(_))
- .Times(0);
+ .Times(1);
volume_->removed.emit();
}
@@ -516,7 +660,7 @@ TEST_F(TestVolumeLauncherIcon, ActivateMounted)
uint64_t time = g_random_int();
InSequence seq;
EXPECT_CALL(*volume_, Mount()).Times(0);
- EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time));
+ EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time));
icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time));
}
@@ -526,7 +670,7 @@ TEST_F(TestVolumeLauncherIcon, ActivateUnmounted)
ON_CALL(*volume_, IsMounted()).WillByDefault(Return(false));
InSequence seq;
EXPECT_CALL(*volume_, Mount());
- EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time));
+ EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time));
icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time));
}