summaryrefslogtreecommitdiff
path: root/tests
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2015-11-24 18:49:45 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2015-11-24 18:49:45 +0100
commit2d3e209255bb3b385c35746c81e7daf0e3aa5e7a (patch)
tree7be4e3182df9754bf063700c9b4eb220aa64cbaa /tests
parentc6c97594ea87e5d7c73c670e065c07fad6e6c282 (diff)
TestTrashLauncherIcon: add some windows related tests
(bzr r4036.11.13)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_trash_launcher_icon.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_trash_launcher_icon.cpp b/tests/test_trash_launcher_icon.cpp
index 9bee957eb..cfeea3cb7 100644
--- a/tests/test_trash_launcher_icon.cpp
+++ b/tests/test_trash_launcher_icon.cpp
@@ -44,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);
@@ -88,6 +94,65 @@ TEST_F(TestTrashLauncherIcon, RunningState)
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();
+ EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE));
+
+ win2->LocalFocus();
+ ApplicationManager::Default().active_window_changed.emit(win2);
+ 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));
+ 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.WindowsForMonitor(0).size(), (windows.size() / 2) + (windows.size() % 2));
+ EXPECT_EQ(icon.WindowsForMonitor(1).size(), 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.WindowsForMonitor(0).size(), 1);
+ EXPECT_EQ(icon.WindowsForMonitor(1).size(), 0);
+
+ win->SetMonitor(1);
+ EXPECT_EQ(icon.WindowsForMonitor(0).size(), 0);
+ EXPECT_EQ(icon.WindowsForMonitor(1).size(), 1);
+}
+
TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection)
{
auto file_manager = std::make_shared<NiceMock<MockFileManager>>();