Merge lp:~azzar1/unity/fix-1033866 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2548
Proposed branch: lp:~azzar1/unity/fix-1033866
Merge into: lp:unity
Diff against target: 173 lines (+65/-12)
5 files modified
launcher/Launcher.h (+2/-0)
launcher/LauncherOptions.cpp (+1/-1)
launcher/MockLauncherIcon.h (+3/-2)
plugins/unityshell/unityshell.xml.in (+1/-1)
tests/test_launcher.cpp (+58/-8)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1033866
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+118531@code.launchpad.net

Commit message

Switch on "backlight toggles" mode by default

Description of the change

== Test ==
Add a test for IconBackgroundItensity with the default option values for backlight mode and start animation.

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

Everything looks good, and the tests pass for me.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in launcher/MockLauncherIcon.h
text conflict in tests/test_launcher.cpp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.h'
2--- launcher/Launcher.h 2012-08-03 09:39:01 +0000
3+++ launcher/Launcher.h 2012-08-13 09:47:28 +0000
4@@ -389,6 +389,8 @@
5
6 UBusManager ubus_;
7 glib::SourceManager sources_;
8+
9+ friend class TestLauncher;
10 };
11
12 }
13
14=== modified file 'launcher/LauncherOptions.cpp'
15--- launcher/LauncherOptions.cpp 2012-07-19 00:00:43 +0000
16+++ launcher/LauncherOptions.cpp 2012-08-13 09:47:28 +0000
17@@ -31,7 +31,7 @@
18 , launch_animation(LAUNCH_ANIMATION_PULSE)
19 , urgent_animation(URGENT_ANIMATION_WIGGLE)
20 , auto_hide_animation(FADE_AND_SLIDE)
21- , backlight_mode(BACKLIGHT_ALWAYS_ON)
22+ , backlight_mode(BACKLIGHT_NORMAL)
23 , reveal_trigger(RevealTrigger::EDGE)
24 , icon_size(48)
25 , tile_size(54)
26
27=== modified file 'launcher/MockLauncherIcon.h'
28--- launcher/MockLauncherIcon.h 2012-08-02 11:30:02 +0000
29+++ launcher/MockLauncherIcon.h 2012-08-13 09:47:28 +0000
30@@ -212,14 +212,14 @@
31 void SetQuirk(Quirk quirk, bool value)
32 {
33 quirks_[unsigned(quirk)] = value;
34+ clock_gettime(CLOCK_MONOTONIC, &(quirk_times_[unsigned(quirk)]));
35 }
36
37 void ResetQuirkTime(Quirk quirk) {};
38
39 struct timespec GetQuirkTime(Quirk quirk)
40 {
41- timespec tv;
42- return tv;
43+ return quirk_times_[unsigned(quirk)];
44 }
45
46 IconType GetIconType()
47@@ -345,6 +345,7 @@
48 int sort_priority_;
49 IconType type_;
50 bool quirks_[unsigned(Quirk::LAST)];
51+ timespec quirk_times_[unsigned(Quirk::LAST)];
52 };
53
54 }
55
56=== modified file 'plugins/unityshell/unityshell.xml.in'
57--- plugins/unityshell/unityshell.xml.in 2012-07-27 03:16:37 +0000
58+++ plugins/unityshell/unityshell.xml.in 2012-08-13 09:47:28 +0000
59@@ -205,7 +205,7 @@
60 <_long>Change how the icons are backlit</_long>
61 <min>0</min>
62 <max>4</max>
63- <default>0</default>
64+ <default>1</default>
65 <desc>
66 <value>0</value>
67 <_name>Backlight Always On</_name>
68
69=== modified file 'tests/test_launcher.cpp'
70--- tests/test_launcher.cpp 2012-08-02 11:30:02 +0000
71+++ tests/test_launcher.cpp 2012-08-13 09:47:28 +0000
72@@ -24,15 +24,23 @@
73 #include <Nux/Nux.h>
74 #include <Nux/BaseWindow.h>
75
76-#include "DNDCollectionWindow.h"
77-#include "MockLauncherIcon.h"
78-#include "Launcher.h"
79+#include "launcher/DNDCollectionWindow.h"
80+#include "launcher/MockLauncherIcon.h"
81+#include "launcher/Launcher.h"
82+#include "unity-shared/PanelStyle.h"
83+#include "unity-shared/UnitySettings.h"
84 #include "test_utils.h"
85 using namespace unity;
86
87+namespace unity
88+{
89+namespace launcher
90+{
91 namespace
92 {
93
94+const int STARTING_ANIMATION_DURATION = 150;
95+
96 class MockMockLauncherIcon : public launcher::MockLauncherIcon
97 {
98 public:
99@@ -41,22 +49,34 @@
100 MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&));
101 };
102
103+}
104+
105 class TestLauncher : public Test
106 {
107 public:
108 TestLauncher()
109 : parent_window_(new nux::BaseWindow("TestLauncherWindow"))
110 , dnd_collection_window_(new DNDCollectionWindow)
111- , model_(new launcher::LauncherModel)
112- , launcher_(new launcher::Launcher(parent_window_, dnd_collection_window_))
113+ , model_(new LauncherModel)
114+ , options_(new Options)
115+ , launcher_(new Launcher(parent_window_, dnd_collection_window_))
116 {
117+ launcher_->options = options_;
118 launcher_->SetModel(model_);
119 }
120
121+ float IconBackgroundIntensity(AbstractLauncherIcon::Ptr icon, timespec const& current) const
122+ {
123+ return launcher_->IconBackgroundIntensity(icon, current);
124+ }
125+
126 nux::BaseWindow* parent_window_;
127 nux::ObjectPtr<DNDCollectionWindow> dnd_collection_window_;
128- launcher::LauncherModel::Ptr model_;
129- nux::ObjectPtr<launcher::Launcher> launcher_;
130+ Settings settings;
131+ panel::Style panel_style;
132+ LauncherModel::Ptr model_;
133+ Options::Ptr options_;
134+ nux::ObjectPtr<Launcher> launcher_;
135 };
136
137 TEST_F(TestLauncher, TestQuirksDuringDnd)
138@@ -89,4 +109,34 @@
139 EXPECT_TRUE(third->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT));
140 }
141
142-}
143+
144+TEST_F(TestLauncher, TestIconBackgroundIntensity)
145+{
146+ MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon);
147+ model_->AddIcon(first);
148+
149+ MockMockLauncherIcon::Ptr second(new MockMockLauncherIcon);
150+ model_->AddIcon(second);
151+
152+ MockMockLauncherIcon::Ptr third(new MockMockLauncherIcon);
153+ model_->AddIcon(third);
154+
155+ options_->backlight_mode = BACKLIGHT_NORMAL;
156+ options_->launch_animation = LAUNCH_ANIMATION_PULSE;
157+
158+ first->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, true);
159+ second->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, true);
160+ third->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, false);
161+
162+ Utils::WaitForTimeoutMSec(STARTING_ANIMATION_DURATION);
163+ timespec current;
164+ clock_gettime(CLOCK_MONOTONIC, &current);
165+
166+ EXPECT_THAT(IconBackgroundIntensity(first, current), Gt(0.0f));
167+ EXPECT_THAT(IconBackgroundIntensity(second, current), Gt(0.0f));
168+ EXPECT_EQ(IconBackgroundIntensity(third, current), 0.0f);
169+}
170+
171+}
172+}
173+