Merge lp:~brandontschaefer/unity/alt-grave-ordering-fix into lp:unity

Proposed by Brandon Schaefer on 2012-10-09
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-10-11
Approved revision: 2819
Merged at revision: 2827
Proposed branch: lp:~brandontschaefer/unity/alt-grave-ordering-fix
Merge into: lp:unity
Diff against target: 85 lines (+52/-2)
3 files modified
launcher/SwitcherModel.cpp (+6/-2)
tests/autopilot/unity/tests/test_switcher.py (+13/-0)
tests/test_switcher_model.cpp (+33/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/alt-grave-ordering-fix
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve on 2012-10-10
Thomi Richards (community) quality 2012-10-09 Approve on 2012-10-09
jenkins continuous-integration Pending
Review via email: mp+128823@code.launchpad.net

Commit message

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.

Description of the change

=== Problem ===
When pressing Alt+grave twice it would focus the active window going into detail mode. It should focus the third window, not the first.

=== Fix ===
Instead of swapping the first and second window, move the first all the way to the end (it being a vector means moving everything over one left)

=== Test ===
AP test

So with this change:

Window order, where 1 is the current focused window:
1,2,3,4,5,6

Pressing Alt+`

Desired result order:
2,3,4,5,6,1

Current result order:
2,1,3,4,5,6

To post a comment you must log in.
Brandon Schaefer (brandontschaefer) wrote :

Running:

autopilot run unity.tests.test_switcher

Ran 54 tests in 461.457s
OK

2818. By Brandon Schaefer on 2012-10-09

* Better assert

review: Approve (quality)
Marco Trevisan (Treviño) (3v1n0) wrote :

Good!

review: Approve
2819. By Brandon Schaefer on 2012-10-10

* Added a unit test

Marco Trevisan (Treviño) (3v1n0) wrote :

Cool thanks for the unit test... Globally approve!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/SwitcherModel.cpp'
--- launcher/SwitcherModel.cpp 2012-10-04 07:10:39 +0000
+++ launcher/SwitcherModel.cpp 2012-10-10 21:23:21 +0000
@@ -162,9 +162,13 @@
162162
163 std::sort(results.begin(), results.end(), compare_windows_by_active);163 std::sort(results.begin(), results.end(), compare_windows_by_active);
164164
165 // swap so we focus the last focused window first
166 if (Selection() == _last_active_icon && results.size () > 1)165 if (Selection() == _last_active_icon && results.size () > 1)
167 std::swap (results[0], results[1]);166 {
167 for (unsigned int i = 0; i < results.size()-1; i++)
168 {
169 std::swap (results[i], results[i+1]);
170 }
171 }
168172
169 return results;173 return results;
170}174}
171175
=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
--- tests/autopilot/unity/tests/test_switcher.py 2012-09-17 10:37:02 +0000
+++ tests/autopilot/unity/tests/test_switcher.py 2012-10-10 21:23:21 +0000
@@ -350,6 +350,19 @@
350350
351 self.assertProperty(char_win1, is_focused=True)351 self.assertProperty(char_win1, is_focused=True)
352352
353 def test_detail_mode_selects_third_window(self):
354 """Pressing Alt+` twice must select the third last used window.
355 LP:1061229
356 """
357 char_win1, char_win2, char_win3 = self.start_applications("Character Map", "Character Map", "Character Map")
358 self.assertVisibleWindowStack([char_win3, char_win2, char_win1])
359
360 self.switcher.initiate(SwitcherMode.DETAIL)
361 self.switcher.next_detail()
362
363 self.switcher.select()
364 self.assertVisibleWindowStack([char_win1, char_win3, char_win2])
365
353366
354class SwitcherWorkspaceTests(SwitcherTestCase):367class SwitcherWorkspaceTests(SwitcherTestCase):
355 """Test Switcher behavior with respect to multiple workspaces."""368 """Test Switcher behavior with respect to multiple workspaces."""
356369
=== modified file 'tests/test_switcher_model.cpp'
--- tests/test_switcher_model.cpp 2012-03-14 06:24:18 +0000
+++ tests/test_switcher_model.cpp 2012-10-10 21:23:21 +0000
@@ -100,4 +100,37 @@
100 EXPECT_EQ(model->LastSelection(), third);100 EXPECT_EQ(model->LastSelection(), third);
101}101}
102102
103TEST(TestSwitcherModel, TestActiveDetailWindowSort)
104{
105 std::vector<AbstractLauncherIcon::Ptr> detail_icons;
106 AbstractLauncherIcon::Ptr detail(new MockLauncherIcon());
107 detail->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true);
108 detail_icons.push_back(detail);
109
110 // Set up a list with out an active icon, so we can assert
111 // the first detail icon == to the last xid of detailed list
112 std::vector<AbstractLauncherIcon::Ptr> icons;
113 AbstractLauncherIcon::Ptr normal(new MockLauncherIcon());
114 icons.push_back(normal);
115
116 SwitcherModel::Ptr model_detail_active(new SwitcherModel(detail_icons));
117 model_detail_active->detail_selection = true;
118
119 SwitcherModel::Ptr model_detail(new SwitcherModel(icons));
120 model_detail->detail_selection = true;
121
122 EXPECT_TRUE(model_detail_active->DetailXids().size() > 2);
123 EXPECT_TRUE(model_detail_active->DetailSelectionWindow() != model_detail->DetailSelectionWindow());
124
125 // Move to the last detailed window
126 for (unsigned int i = 0; i < model_detail_active->DetailXids().size() - 1; i++)
127 model_detail_active->NextDetail();
128
129 Window sorted, unsorted;
130 sorted = model_detail_active->DetailSelectionWindow();
131 unsorted = model_detail->DetailSelectionWindow();
132
133 EXPECT_EQ(sorted, unsorted);
134}
135
103}136}