Merge lp:~3v1n0/unity/switcher-disable-detail-on-init into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3131
Proposed branch: lp:~3v1n0/unity/switcher-disable-detail-on-init
Merge into: lp:unity
Diff against target: 65 lines (+24/-1)
2 files modified
launcher/SwitcherController.cpp (+1/-0)
tests/test_switcher_controller.cpp (+23/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/switcher-disable-detail-on-init
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+146757@code.launchpad.net

Commit message

SwitcherController: remove the detail timeout when the detail mode is changed

Description of the change

When enabling the detail mode manually, the detail timeout should be removed, or it could cause the detail-mode to be re-enabled accidentally (it happens when quickly opening/closing it after selecting an icon).

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherController.cpp'
2--- launcher/SwitcherController.cpp 2013-02-05 02:12:11 +0000
3+++ launcher/SwitcherController.cpp 2013-02-06 00:41:22 +0000
4@@ -261,6 +261,7 @@
5 model_ = std::make_shared<SwitcherModel>(results);
6 obj_->AddChild(model_.get());
7 model_->selection_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnModelSelectionChanged));
8+ model_->detail_selection.changed.connect([this] (bool) { sources_.Remove(DETAIL_TIMEOUT); });
9 model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT);
10
11 SelectFirstItem();
12
13=== modified file 'tests/test_switcher_controller.cpp'
14--- tests/test_switcher_controller.cpp 2013-01-22 20:50:14 +0000
15+++ tests/test_switcher_controller.cpp 2013-02-06 00:41:22 +0000
16@@ -158,6 +158,7 @@
17 static const int initial_details_timeout = 500;
18 static const int details_timeout = 10 * initial_details_timeout;
19
20+ controller_->detail_on_timeout = true;
21 controller_->initial_detail_timeout_length = initial_details_timeout;
22 controller_->detail_timeout_length = details_timeout;
23
24@@ -177,12 +178,13 @@
25 EXPECT_TRUE(time_diff < details_timeout);
26 }
27
28-TEST_F(TestSwitcherController, DetailTimeout)
29+TEST_F(TestSwitcherController, DetailTimeoutRemoval)
30 {
31 Clock::time_point start_time = Clock::now();
32 static const int details_timeout = 500;
33 static const int initial_details_timeout = 10 * details_timeout;
34
35+ controller_->detail_on_timeout = true;
36 controller_->detail_timeout_length = details_timeout;
37 controller_->initial_detail_timeout_length = initial_details_timeout;
38
39@@ -213,6 +215,26 @@
40 EXPECT_TRUE(time_diff < initial_details_timeout);
41 }
42
43+TEST_F(TestSwitcherController, DetailTimeoutOnDetailActivate)
44+{
45+ static const int initial_details_timeout = 500;
46+ static const int details_timeout = 10 * initial_details_timeout;
47+
48+ controller_->detail_on_timeout = true;
49+ controller_->initial_detail_timeout_length = initial_details_timeout;
50+ controller_->detail_timeout_length = details_timeout;
51+
52+ controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
53+ EXPECT_EQ(controller_->GetCurrentSelection().window_, 0);
54+
55+ // Manually open-close the detail mode before that the timeout has occurred
56+ controller_->SetDetail(true);
57+ controller_->SetDetail(false);
58+
59+ Utils::WaitForTimeoutMSec(initial_details_timeout * 1.1);
60+ EXPECT_EQ(controller_->GetCurrentSelection().window_, 0);
61+}
62+
63 TEST_F(TestSwitcherController, ShowSwitcher)
64 {
65 EXPECT_FALSE(controller_->Visible());