Merge lp:~azzar1/unity/test-for-fix-1020891 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2501
Proposed branch: lp:~azzar1/unity/test-for-fix-1020891
Merge into: lp:unity
Diff against target: 300 lines (+145/-8)
10 files modified
launcher/CMakeLists.txt (+1/-0)
launcher/Launcher.cpp (+2/-1)
launcher/Launcher.h (+1/-1)
launcher/LauncherController.cpp (+1/-1)
launcher/MockLauncherIcon.cpp (+31/-0)
launcher/MockLauncherIcon.h (+11/-4)
plugins/unityshell/src/unitya11ytests.cpp (+1/-1)
tests/CMakeLists.txt (+3/-0)
tests/test_launcher.cpp (+92/-0)
tests/test_main.cpp (+2/-0)
To merge this branch: bzr merge lp:~azzar1/unity/test-for-fix-1020891
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
jenkins (community) continuous-integration Approve
Review via email: mp+114706@code.launchpad.net

Commit message

Add test for bug 1020891.

Description of the change

I used gtest because faking xdnd protocol with AP is not so easy.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gord Allott (gordallott) wrote :

no problems that i can see

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/CMakeLists.txt'
2--- launcher/CMakeLists.txt 2012-07-06 10:20:29 +0000
3+++ launcher/CMakeLists.txt 2012-07-12 19:07:42 +0000
4@@ -57,6 +57,7 @@
5 LauncherIcon.cpp
6 LauncherModel.cpp
7 LauncherOptions.cpp
8+ MockLauncherIcon.cpp
9 PointerBarrier.cpp
10 QuicklistManager.cpp
11 QuicklistMenuItem.cpp
12
13=== modified file 'launcher/Launcher.cpp'
14--- launcher/Launcher.cpp 2012-07-11 05:46:00 +0000
15+++ launcher/Launcher.cpp 2012-07-12 19:07:42 +0000
16@@ -104,6 +104,7 @@
17 const int Launcher::Launcher::ANIM_DURATION_SHORT = 125;
18
19 Launcher::Launcher(nux::BaseWindow* parent,
20+ nux::ObjectPtr<DNDCollectionWindow> const& collection_window,
21 NUX_FILE_LINE_DECL)
22 : View(NUX_FILE_LINE_PARAM)
23 , monitor(0)
24@@ -140,12 +141,12 @@
25 , _drag_out_id(0)
26 , _drag_out_delta_x(0.0f)
27 , _last_reveal_progress(0.0f)
28+ , _collection_window(collection_window)
29 , _selection_atom(0)
30 , _background_color(nux::color::DimGray)
31 {
32 m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
33
34- _collection_window = new unity::DNDCollectionWindow();
35 _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));
36
37 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);
38
39=== modified file 'launcher/Launcher.h'
40--- launcher/Launcher.h 2012-06-18 02:57:23 +0000
41+++ launcher/Launcher.h 2012-07-12 19:07:42 +0000
42@@ -56,7 +56,7 @@
43 NUX_DECLARE_OBJECT_TYPE(Launcher, nux::View);
44 public:
45
46- Launcher(nux::BaseWindow* parent, NUX_FILE_LINE_PROTO);
47+ Launcher(nux::BaseWindow* parent, nux::ObjectPtr<DNDCollectionWindow> const& collection_window, NUX_FILE_LINE_PROTO);
48
49 nux::Property<Display*> display;
50 nux::Property<int> monitor;
51
52=== modified file 'launcher/LauncherController.cpp'
53--- launcher/LauncherController.cpp 2012-07-09 11:26:46 +0000
54+++ launcher/LauncherController.cpp 2012-07-12 19:07:42 +0000
55@@ -391,7 +391,7 @@
56 {
57 nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow"));
58
59- Launcher* launcher = new Launcher(launcher_window);
60+ Launcher* launcher = new Launcher(launcher_window, nux::ObjectPtr<DNDCollectionWindow>(new DNDCollectionWindow));
61 launcher->display = display_;
62 launcher->monitor = monitor;
63 launcher->options = parent_->options();
64
65=== added file 'launcher/MockLauncherIcon.cpp'
66--- launcher/MockLauncherIcon.cpp 1970-01-01 00:00:00 +0000
67+++ launcher/MockLauncherIcon.cpp 2012-07-12 19:07:42 +0000
68@@ -0,0 +1,31 @@
69+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
70+/*
71+ * Copyright (C) 2012 Canonical Ltd
72+ *
73+ * This program is free software: you can redistribute it and/or modify
74+ * it under the terms of the GNU General Public License version 3 as
75+ * published by the Free Software Foundation.
76+ *
77+ * This program is distributed in the hope that it will be useful,
78+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
79+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80+ * GNU General Public License for more details.
81+ *
82+ * You should have received a copy of the GNU General Public License
83+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
84+ *
85+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
86+ *
87+ */
88+
89+#include "MockLauncherIcon.h"
90+
91+namespace unity
92+{
93+namespace launcher
94+{
95+
96+NUX_IMPLEMENT_OBJECT_TYPE(MockLauncherIcon);
97+
98+}
99+}
100
101=== modified file 'launcher/MockLauncherIcon.h'
102--- launcher/MockLauncherIcon.h 2012-05-28 16:16:06 +0000
103+++ launcher/MockLauncherIcon.h 2012-07-12 19:07:42 +0000
104@@ -50,6 +50,11 @@
105 tooltip_text = "Mock Icon";
106 sort_priority_ = 0;
107 type_ = TYPE_APPLICATION;
108+
109+ for (int i = 0; i < QUIRK_LAST; ++i)
110+ {
111+ quirks_[i] = false;
112+ }
113 }
114
115 std::string GetName() const { return "MockLauncherIcon"; }
116@@ -201,10 +206,13 @@
117
118 bool GetQuirk(Quirk quirk) const
119 {
120- return false;
121+ return quirks_[quirk];
122 }
123
124- void SetQuirk(Quirk quirk, bool value) {}
125+ void SetQuirk(Quirk quirk, bool value)
126+ {
127+ quirks_[quirk] = value;
128+ }
129
130 void ResetQuirkTime(Quirk quirk) {};
131
132@@ -336,10 +344,9 @@
133 nux::BaseTexture* icon_;
134 int sort_priority_;
135 IconType type_;
136+ bool quirks_[QUIRK_LAST];
137 };
138
139-NUX_IMPLEMENT_OBJECT_TYPE(MockLauncherIcon);
140-
141 }
142 }
143
144
145=== modified file 'plugins/unityshell/src/unitya11ytests.cpp'
146--- plugins/unityshell/src/unitya11ytests.cpp 2012-03-14 06:24:18 +0000
147+++ plugins/unityshell/src/unitya11ytests.cpp 2012-07-12 19:07:42 +0000
148@@ -210,7 +210,7 @@
149 AtkObject* launcher_icon_accessible = NULL;
150
151 window = new nux::BaseWindow(TEXT(""));
152- launcher = new Launcher(window, NULL);
153+ launcher = new Launcher(window, nux::ObjectPtr<unity::DNDCollectionWindow>(new unity::DNDCollectionWindow), NULL);
154 launcher->SinkReference();
155 launcher_accessible = unity_a11y_get_accessible(launcher);
156
157
158=== modified file 'tests/CMakeLists.txt'
159--- tests/CMakeLists.txt 2012-07-04 02:37:23 +0000
160+++ tests/CMakeLists.txt 2012-07-12 19:07:42 +0000
161@@ -159,6 +159,7 @@
162 ${CMAKE_SOURCE_DIR}/unity-shared/IconTextureSource.cpp
163 ${CMAKE_SOURCE_DIR}/launcher/LauncherModel.cpp
164 ${CMAKE_SOURCE_DIR}/launcher/LauncherEntryRemote.cpp
165+ ${CMAKE_SOURCE_DIR}/launcher/MockLauncherIcon.cpp
166 ${CMAKE_SOURCE_DIR}/launcher/FavoriteStorePrivate.cpp
167 ${CMAKE_SOURCE_DIR}/shortcuts/ShortcutModel.cpp
168 ${CMAKE_SOURCE_DIR}/shortcuts/ShortcutHintPrivate.cpp
169@@ -205,6 +206,7 @@
170 test_dashview_impl.cpp
171 test_texture_cache.cpp
172 test_main.cpp
173+ test_launcher.cpp
174 test_lensview_impl.cpp
175 test_icon_loader.cpp
176 test_im_text_entry.cpp
177@@ -245,6 +247,7 @@
178 ${CMAKE_SOURCE_DIR}/launcher/LauncherIcon.cpp
179 ${CMAKE_SOURCE_DIR}/launcher/LauncherModel.cpp
180 ${CMAKE_SOURCE_DIR}/launcher/LayoutSystem.cpp
181+ ${CMAKE_SOURCE_DIR}/launcher/MockLauncherIcon.cpp
182 ${CMAKE_SOURCE_DIR}/launcher/PointerBarrier.cpp
183 ${CMAKE_SOURCE_DIR}/launcher/QuicklistManager.cpp
184 ${CMAKE_SOURCE_DIR}/launcher/QuicklistMenuItem.cpp
185
186=== added file 'tests/test_launcher.cpp'
187--- tests/test_launcher.cpp 1970-01-01 00:00:00 +0000
188+++ tests/test_launcher.cpp 2012-07-12 19:07:42 +0000
189@@ -0,0 +1,92 @@
190+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
191+/*
192+ * Copyright (C) 2012 Canonical Ltd
193+ *
194+ * This program is free software: you can redistribute it and/or modify
195+ * it under the terms of the GNU General Public License version 3 as
196+ * published by the Free Software Foundation.
197+ *
198+ * This program is distributed in the hope that it will be useful,
199+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
200+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201+ * GNU General Public License for more details.
202+ *
203+ * You should have received a copy of the GNU General Public License
204+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
205+ *
206+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
207+ */
208+
209+#include <list>
210+#include <gmock/gmock.h>
211+using namespace testing;
212+
213+#include <Nux/Nux.h>
214+#include <Nux/BaseWindow.h>
215+
216+#include "DNDCollectionWindow.h"
217+#include "MockLauncherIcon.h"
218+#include "Launcher.h"
219+#include "test_utils.h"
220+using namespace unity;
221+
222+namespace
223+{
224+
225+class MockMockLauncherIcon : public launcher::MockLauncherIcon
226+{
227+public:
228+ typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr;
229+
230+ MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&));
231+};
232+
233+class TestLauncher : public Test
234+{
235+public:
236+ TestLauncher()
237+ : parent_window_(new nux::BaseWindow("TestLauncherWindow"))
238+ , dnd_collection_window_(new DNDCollectionWindow)
239+ , model_(new launcher::LauncherModel)
240+ , launcher_(new launcher::Launcher(parent_window_, dnd_collection_window_))
241+ {
242+ launcher_->SetModel(model_);
243+ }
244+
245+ nux::BaseWindow* parent_window_;
246+ nux::ObjectPtr<DNDCollectionWindow> dnd_collection_window_;
247+ launcher::LauncherModel::Ptr model_;
248+ nux::ObjectPtr<launcher::Launcher> launcher_;
249+};
250+
251+TEST_F(TestLauncher, TestQuirksDuringDnd)
252+{
253+ MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon);
254+ model_->AddIcon(first);
255+
256+ MockMockLauncherIcon::Ptr second(new MockMockLauncherIcon);
257+ model_->AddIcon(second);
258+
259+ MockMockLauncherIcon::Ptr third(new MockMockLauncherIcon);
260+ model_->AddIcon(third);
261+
262+ EXPECT_CALL(*first, ShouldHighlightOnDrag(_))
263+ .WillRepeatedly(Return(true));
264+
265+ EXPECT_CALL(*second, ShouldHighlightOnDrag(_))
266+ .WillRepeatedly(Return(true));
267+
268+ EXPECT_CALL(*third, ShouldHighlightOnDrag(_))
269+ .WillRepeatedly(Return(false));
270+
271+ std::list<char*> uris;
272+ dnd_collection_window_->collected.emit(uris);
273+
274+ Utils::WaitForTimeout(1);
275+
276+ EXPECT_FALSE(first->GetQuirk(launcher::AbstractLauncherIcon::QUIRK_DESAT));
277+ EXPECT_FALSE(second->GetQuirk(launcher::AbstractLauncherIcon::QUIRK_DESAT));
278+ EXPECT_TRUE(third->GetQuirk(launcher::AbstractLauncherIcon::QUIRK_DESAT));
279+}
280+
281+}
282
283=== modified file 'tests/test_main.cpp'
284--- tests/test_main.cpp 2012-06-21 06:55:53 +0000
285+++ tests/test_main.cpp 2012-07-12 19:07:42 +0000
286@@ -4,6 +4,7 @@
287 #include <NuxCore/Logger.h>
288 #include <Nux/Nux.h>
289
290+#include "GestureEngine.h"
291 #include "unity-shared/PluginAdapter.h"
292 #include "unity-shared/WindowManager.h"
293
294@@ -26,6 +27,7 @@
295 // Setting the PluginAdapter to null, using the Standalone version at link time.
296 PluginAdapter::Initialize(NULL);
297 WindowManager::SetDefault(PluginAdapter::Default());
298+ GeisAdapter geis_adapter;
299
300 int ret = RUN_ALL_TESTS();
301