Merge lp:~3v1n0/unity/session-shutdown-buttons-reorder into lp:unity

Proposed by Marco Trevisan (Treviño) on 2013-03-19
Status: Merged
Approved by: Andrea Azzarone on 2013-03-19
Approved revision: 3235
Merged at revision: 3233
Proposed branch: lp:~3v1n0/unity/session-shutdown-buttons-reorder
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/session-labels-fix
Diff against target: 86 lines (+28/-14)
2 files modified
shutdown/SessionView.cpp (+5/-5)
tests/test_session_view.cpp (+23/-9)
To merge this branch: bzr merge lp:~3v1n0/unity/session-shutdown-buttons-reorder
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2013-03-19
Andrea Azzarone 2013-03-19 Approve on 2013-03-19
Review via email: mp+154120@code.launchpad.net

Commit message

SessionView: invert the position of reboot/shutdown buttons

Description of the change

Invert the position of the reboot/shutdown buttons as requested by design.

Tests added/updated.

To post a comment you must log in.
Andrea Azzarone (azzar1) :
review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shutdown/SessionView.cpp'
2--- shutdown/SessionView.cpp 2013-03-19 15:24:25 +0000
3+++ shutdown/SessionView.cpp 2013-03-19 15:24:25 +0000
4@@ -206,13 +206,13 @@
5
6 if (manager_->CanShutdown())
7 {
8- auto* button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION);
9+ auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION);
10+ button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot));
11+ AddButton(button);
12+
13+ button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION);
14 button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown));
15 AddButton(button);
16-
17- button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION);
18- button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot));
19- AddButton(button);
20 }
21 else if (mode() == Mode::FULL)
22 {
23
24=== modified file 'tests/test_session_view.cpp'
25--- tests/test_session_view.cpp 2013-03-19 15:24:25 +0000
26+++ tests/test_session_view.cpp 2013-03-19 15:24:25 +0000
27@@ -70,6 +70,20 @@
28
29 return nullptr;
30 }
31+
32+ int GetButtonPosition(Button::Action action) const
33+ {
34+ int pos = 0;
35+ for (auto const& button : GetButtons())
36+ {
37+ if (button->action() == action)
38+ return pos;
39+
40+ ++pos;
41+ }
42+
43+ return -1;
44+ }
45 };
46
47 void TearDown()
48@@ -130,11 +144,11 @@
49 view.mode.changed.emit(View::Mode::FULL);
50
51 EXPECT_EQ(view.GetButtonByAction(Button::Action::LOGOUT), nullptr);
52- EXPECT_NE(view.GetButtonByAction(Button::Action::LOCK), nullptr);
53- EXPECT_NE(view.GetButtonByAction(Button::Action::SUSPEND), nullptr);
54- EXPECT_NE(view.GetButtonByAction(Button::Action::HIBERNATE), nullptr);
55- EXPECT_NE(view.GetButtonByAction(Button::Action::SHUTDOWN), nullptr);
56- EXPECT_NE(view.GetButtonByAction(Button::Action::REBOOT), nullptr);
57+ EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0);
58+ EXPECT_EQ(view.GetButtonPosition(Button::Action::SUSPEND), 1);
59+ EXPECT_EQ(view.GetButtonPosition(Button::Action::HIBERNATE), 2);
60+ EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 3);
61+ EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 4);
62
63 ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(false));
64 view.mode.changed.emit(View::Mode::FULL);
65@@ -160,8 +174,8 @@
66 view.mode = View::Mode::SHUTDOWN;
67
68 EXPECT_EQ(view.GetButtons().size(), 2);
69- EXPECT_NE(view.GetButtonByAction(Button::Action::SHUTDOWN), nullptr);
70- EXPECT_NE(view.GetButtonByAction(Button::Action::REBOOT), nullptr);
71+ EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 0);
72+ EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 1);
73 }
74
75 TEST_F(TestSessionView, LogoutModeButtons)
76@@ -169,8 +183,8 @@
77 view.mode = View::Mode::LOGOUT;
78
79 EXPECT_EQ(view.GetButtons().size(), 2);
80- EXPECT_NE(view.GetButtonByAction(Button::Action::LOGOUT), nullptr);
81- EXPECT_NE(view.GetButtonByAction(Button::Action::LOCK), nullptr);
82+ EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0);
83+ EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 1);
84 }
85
86 TEST_F(TestSessionView, FullModeTitle)