summaryrefslogtreecommitdiff
diff options
authorBrandon Schaefer <brandon.schaefer@canonical.com>2012-10-11 10:28:35 +0000
committerTarmac <>2012-10-11 10:28:35 +0000
commita32dbba4ac890d5430335264f8da3db16568d707 (patch)
tree181a7f486d4c1e057e989e2eeb547a72664fbf65
parentabcfeecdf865969ea560e734789f7b4bb0c22b63 (diff)
parente568f081378ca24a8a669cc18b1025b4c82bbf09 (diff)
Changes the swapping order of the detail mode. Now the currently active window gets moved to the end, instead of getting swapped with the last used window.. Fixes: https://bugs.launchpad.net/bugs/1061229. Approved by Marco Trevisan (TreviƱo), Thomi Richards.
Original authors: - Brandon Schaefer <brandon.schaefer@canonical.com> - MC Return <mc.return@gmx.net> (bzr r2827)
-rw-r--r--launcher/SwitcherModel.cpp8
-rw-r--r--tests/autopilot/unity/tests/test_switcher.py13
-rw-r--r--tests/test_switcher_model.cpp33
3 files changed, 52 insertions, 2 deletions
diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp
index 3c0648b38..931ecb18d 100644
--- a/launcher/SwitcherModel.cpp
+++ b/launcher/SwitcherModel.cpp
@@ -162,9 +162,13 @@ std::vector<Window> SwitcherModel::DetailXids()
std::sort(results.begin(), results.end(), compare_windows_by_active);
- // swap so we focus the last focused window first
if (Selection() == _last_active_icon && results.size () > 1)
- std::swap (results[0], results[1]);
+ {
+ for (unsigned int i = 0; i < results.size()-1; i++)
+ {
+ std::swap (results[i], results[i+1]);
+ }
+ }
return results;
}
diff --git a/tests/autopilot/unity/tests/test_switcher.py b/tests/autopilot/unity/tests/test_switcher.py
index 3abfdf235..345b6ef5c 100644
--- a/tests/autopilot/unity/tests/test_switcher.py
+++ b/tests/autopilot/unity/tests/test_switcher.py
@@ -350,6 +350,19 @@ class SwitcherDetailsModeTests(SwitcherTestCase):
self.assertProperty(char_win1, is_focused=True)
+ def test_detail_mode_selects_third_window(self):
+ """Pressing Alt+` twice must select the third last used window.
+ LP:1061229
+ """
+ char_win1, char_win2, char_win3 = self.start_applications("Character Map", "Character Map", "Character Map")
+ self.assertVisibleWindowStack([char_win3, char_win2, char_win1])
+
+ self.switcher.initiate(SwitcherMode.DETAIL)
+ self.switcher.next_detail()
+
+ self.switcher.select()
+ self.assertVisibleWindowStack([char_win1, char_win3, char_win2])
+
class SwitcherWorkspaceTests(SwitcherTestCase):
"""Test Switcher behavior with respect to multiple workspaces."""
diff --git a/tests/test_switcher_model.cpp b/tests/test_switcher_model.cpp
index 8529fb470..9066dd46b 100644
--- a/tests/test_switcher_model.cpp
+++ b/tests/test_switcher_model.cpp
@@ -100,4 +100,37 @@ TEST(TestSwitcherModel, TestSelection)
EXPECT_EQ(model->LastSelection(), third);
}
+TEST(TestSwitcherModel, TestActiveDetailWindowSort)
+{
+ std::vector<AbstractLauncherIcon::Ptr> detail_icons;
+ AbstractLauncherIcon::Ptr detail(new MockLauncherIcon());
+ detail->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true);
+ detail_icons.push_back(detail);
+
+ // Set up a list with out an active icon, so we can assert
+ // the first detail icon == to the last xid of detailed list
+ std::vector<AbstractLauncherIcon::Ptr> icons;
+ AbstractLauncherIcon::Ptr normal(new MockLauncherIcon());
+ icons.push_back(normal);
+
+ SwitcherModel::Ptr model_detail_active(new SwitcherModel(detail_icons));
+ model_detail_active->detail_selection = true;
+
+ SwitcherModel::Ptr model_detail(new SwitcherModel(icons));
+ model_detail->detail_selection = true;
+
+ EXPECT_TRUE(model_detail_active->DetailXids().size() > 2);
+ EXPECT_TRUE(model_detail_active->DetailSelectionWindow() != model_detail->DetailSelectionWindow());
+
+ // Move to the last detailed window
+ for (unsigned int i = 0; i < model_detail_active->DetailXids().size() - 1; i++)
+ model_detail_active->NextDetail();
+
+ Window sorted, unsorted;
+ sorted = model_detail_active->DetailSelectionWindow();
+ unsorted = model_detail->DetailSelectionWindow();
+
+ EXPECT_EQ(sorted, unsorted);
+}
+
}