2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
1 |
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
|
2 |
/*
|
|
3 |
* Copyright (C) 2012 Canonical Ltd
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License version 3 as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
*
|
|
17 |
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
|
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
18 |
* Marco Trevisan <marco.trevisan@canonical.com>
|
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
19 |
*/
|
20 |
||
21 |
#include <list> |
|
22 |
#include <gmock/gmock.h> |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
23 |
#include "test_uscreen_mock.h" |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
24 |
using namespace testing; |
25 |
||
26 |
#include <Nux/Nux.h> |
|
27 |
#include <Nux/BaseWindow.h> |
|
28 |
||
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
29 |
#include "launcher/MockLauncherIcon.h" |
30 |
#include "launcher/Launcher.h" |
|
31 |
#include "unity-shared/PanelStyle.h" |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
32 |
#include "unity-shared/IconRenderer.h" |
3566.4.21
by Marco Trevisan (Treviño)
TestLauncher: add IsOverlayOpen tests |
33 |
#include "unity-shared/UBusMessages.h" |
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
34 |
#include "unity-shared/UnitySettings.h" |
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
35 |
#include "test_standalone_wm.h" |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
36 |
#include "test_utils.h" |
37 |
||
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
38 |
namespace unity |
39 |
{
|
|
40 |
namespace launcher |
|
41 |
{
|
|
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
42 |
namespace
|
43 |
{
|
|
44 |
||
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
45 |
const int STARTING_ANIMATION_DURATION = 150; |
46 |
||
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
47 |
class MockMockLauncherIcon : public launcher::MockLauncherIcon |
48 |
{
|
|
49 |
public: |
|
50 |
typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr; |
|
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
51 |
typedef testing::NiceMock<MockMockLauncherIcon> Nice; |
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
52 |
|
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
53 |
MockMockLauncherIcon(IconType type = IconType::APPLICATION) |
54 |
: MockLauncherIcon(type) |
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
55 |
{
|
56 |
ON_CALL(*this, SetQuirk(_, _, _)).WillByDefault(Invoke([this] (ApplicationLauncherIcon::Quirk q, bool v, int m) { MockLauncherIcon::SetQuirk(q, v, m); })); |
|
57 |
ON_CALL(*this, SetQuirk(_, _)).WillByDefault(Invoke([this] (ApplicationLauncherIcon::Quirk q, bool v) { MockLauncherIcon::SetQuirk(q, v); })); |
|
58 |
ON_CALL(*this, SkipQuirkAnimation(_, _)).WillByDefault(Invoke([this] (ApplicationLauncherIcon::Quirk q, int m) { MockLauncherIcon::SkipQuirkAnimation(q, m); })); |
|
59 |
}
|
|
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
60 |
|
61 |
MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&)); |
|
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
62 |
MOCK_METHOD1(Stick, void(bool)); |
3096.5.1
by Andrea Azzarone
Add AbstractLauncherIicon::PerformScroll function. |
63 |
MOCK_METHOD2(PerformScroll, void(ScrollDirection, Time)); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
64 |
MOCK_METHOD0(HideTooltip, void()); |
4067.4.15
by handsome_feng
fix the problem in tooltip |
65 |
MOCK_METHOD0(PromptHideTooltip, void()); |
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
66 |
MOCK_METHOD3(SetQuirk, void(ApplicationLauncherIcon::Quirk, bool, int)); |
67 |
MOCK_METHOD2(SetQuirk, void(ApplicationLauncherIcon::Quirk, bool)); |
|
68 |
MOCK_METHOD2(SkipQuirkAnimation, void(ApplicationLauncherIcon::Quirk, int)); |
|
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
69 |
};
|
70 |
||
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
71 |
}
|
72 |
||
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
73 |
class TestLauncher : public Test |
74 |
{
|
|
75 |
public: |
|
2529.14.92
by Marco Trevisan (Treviño)
TestSoftwareCenterLauncherIcon: added animation test |
76 |
class MockLauncher : public Launcher |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
77 |
{
|
78 |
public: |
|
3180.2.3
by Marco Trevisan (Treviño)
Launcher: use a MockableBaseWindow as parent, and don't enable input windows if not needed |
79 |
MockLauncher(MockableBaseWindow* parent) |
2898.4.7
by Andrea Azzarone
Use the new classes in real code. |
80 |
: Launcher(parent) |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
81 |
{}
|
82 |
||
3256.1.1
by Brandon Schaefer
* If a ProcessDndLeave happens check if we are in an External Drag state |
83 |
void SetExternalDragState() |
84 |
{
|
|
85 |
SetActionState(Launcher::LauncherActionState::ACTION_DRAG_EXTERNAL); |
|
86 |
}
|
|
87 |
||
88 |
bool IsExternalDragState() |
|
89 |
{
|
|
90 |
return GetActionState() == Launcher::LauncherActionState::ACTION_DRAG_EXTERNAL; |
|
91 |
}
|
|
92 |
||
3494.5.12
by Marco Trevisan (Treviño)
TestLauncher: verify that the correct action state is set on drag cancel |
93 |
bool IsActionStateDragCancelled() |
94 |
{
|
|
95 |
return GetActionState() == Launcher::LauncherActionState::ACTION_DRAG_ICON_CANCELLED; |
|
96 |
}
|
|
97 |
||
2761.4.1
by Marco Trevisan (Treviño)
AbstractLauncherIcon: use everywhere (when possible) AbstractLauncherIcon::Ptr const& |
98 |
AbstractLauncherIcon::Ptr MouseIconIntersection(int x, int y) const |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
99 |
{
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
100 |
for (auto const& icon : *model_) |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
101 |
{
|
102 |
auto const& center = icon->GetCenter(monitor()); |
|
103 |
||
104 |
if (y > center.y - GetIconSize()/2.0f && y < center.y + GetIconSize()/2.0f) |
|
105 |
return icon; |
|
106 |
}
|
|
107 |
||
108 |
return AbstractLauncherIcon::Ptr(); |
|
109 |
}
|
|
110 |
||
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
111 |
using Launcher::IconBackgroundIntensity; |
112 |
using Launcher::StartIconDrag; |
|
113 |
using Launcher::ShowDragWindow; |
|
114 |
using Launcher::EndIconDrag; |
|
115 |
using Launcher::UpdateDragWindowPosition; |
|
116 |
using Launcher::HideDragWindow; |
|
117 |
using Launcher::ResetMouseDragState; |
|
118 |
using Launcher::DndIsSpecialRequest; |
|
119 |
using Launcher::ProcessDndEnter; |
|
120 |
using Launcher::ProcessDndLeave; |
|
121 |
using Launcher::ProcessDndMove; |
|
122 |
using Launcher::ProcessDndDrop; |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
123 |
using Launcher::drag_icon_position_; |
124 |
using Launcher::icon_under_mouse_; |
|
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
125 |
using Launcher::IconStartingBlinkValue; |
126 |
using Launcher::IconStartingPulseValue; |
|
3129.1.6
by Marco Trevisan (Treviño)
TestEdgeBarrierController / TestLauncher: fix tests against new API |
127 |
using Launcher::HandleBarrierEvent; |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
128 |
using Launcher::SetHidden; |
3320.1.8
by Chris Townsend
Add tests for checking the handling of the urgent timer functions. |
129 |
using Launcher::HandleUrgentIcon; |
130 |
using Launcher::SetUrgentTimer; |
|
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
131 |
using Launcher::SetIconUnderMouse; |
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
132 |
using Launcher::OnUrgentTimeout; |
3566.4.19
by Marco Trevisan (Treviño)
TestLauncher: verify icon desaturation when it's added on overlay opened |
133 |
using Launcher::IsOverlayOpen; |
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
134 |
using Launcher::sources_; |
135 |
using Launcher::animating_urgent_icons_; |
|
136 |
using Launcher::urgent_animation_period_; |
|
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
137 |
|
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
138 |
void FakeProcessDndMove(int x, int y, std::list<std::string> uris) |
139 |
{
|
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
140 |
dnd_data_.Reset(); |
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
141 |
|
142 |
std::string data_uri; |
|
143 |
for (std::string const& uri : uris) |
|
144 |
data_uri += uri+"\r\n"; |
|
145 |
||
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
146 |
dnd_data_.Fill(data_uri.c_str()); |
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
147 |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
148 |
if (std::find_if(dnd_data_.Uris().begin(), dnd_data_.Uris().end(), [this] (std::string const& uri) |
149 |
{return DndIsSpecialRequest(uri);}) != dnd_data_.Uris().end()) |
|
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
150 |
{
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
151 |
steal_drag_ = true; |
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
152 |
}
|
153 |
||
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
154 |
dnd_hovered_icon_ = MouseIconIntersection(x, y); |
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
155 |
}
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
156 |
};
|
157 |
||
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
158 |
TestLauncher() |
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
159 |
: parent_window_(new MockableBaseWindow("TestLauncherWindow")) |
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
160 |
, model_(new LauncherModel) |
161 |
, options_(new Options) |
|
3058.2.1
by Brandon Schaefer
* Fixed 2 crashing unit test |
162 |
, launcher_(new MockLauncher(parent_window_.GetPointer())) |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
163 |
{
|
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
164 |
launcher_->options = options_; |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
165 |
launcher_->SetModel(model_); |
166 |
}
|
|
167 |
||
3656.2.18
by Marco Trevisan (Treviño)
StandaloneWindowManager: emit signals when expo/spread state changed |
168 |
std::vector<MockMockLauncherIcon::Ptr> AddMockIcons(unsigned number, AbstractLauncherIcon::IconType type = AbstractLauncherIcon::IconType::APPLICATION) |
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
169 |
{
|
170 |
std::vector<MockMockLauncherIcon::Ptr> icons; |
|
171 |
int icon_size = launcher_->GetIconSize(); |
|
172 |
int monitor = launcher_->monitor(); |
|
173 |
auto const& launcher_geo = launcher_->GetGeometry(); |
|
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
174 |
int model_pre_size = model_->Size(); |
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
175 |
|
176 |
for (unsigned i = 0; i < number; ++i) |
|
177 |
{
|
|
3656.2.18
by Marco Trevisan (Treviño)
StandaloneWindowManager: emit signals when expo/spread state changed |
178 |
MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon::Nice(type)); |
3536.3.22
by Marco Trevisan (Treviño)
LauncherIcon: don't save parent geometries anymore, SetCenter should now include them |
179 |
icon->SetCenter(nux::Point3(launcher_geo.x + icon_size/2.0f, launcher_geo.y + icon_size/2.0f * (i+1) + 1, 0), monitor); |
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
180 |
|
181 |
icons.push_back(icon); |
|
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
182 |
model_->AddIcon(icon); |
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
183 |
}
|
184 |
||
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
185 |
EXPECT_EQ(icons.size(), number); |
186 |
EXPECT_EQ(model_pre_size + number, number); |
|
187 |
||
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
188 |
return icons; |
189 |
}
|
|
190 |
||
3566.9.5
by Brandon Schaefer
* Fix unit tests (need a unity::Settings instance) |
191 |
panel::Style panel_style; |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
192 |
MockUScreen uscreen; |
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
193 |
testwrapper::StandaloneWM WM; |
3180.2.3
by Marco Trevisan (Treviño)
Launcher: use a MockableBaseWindow as parent, and don't enable input windows if not needed |
194 |
nux::ObjectPtr<MockableBaseWindow> parent_window_; |
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
195 |
LauncherModel::Ptr model_; |
196 |
Options::Ptr options_; |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
197 |
nux::ObjectPtr<MockLauncher> launcher_; |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
198 |
};
|
199 |
||
2740.3.2
by Marco Trevisan (Treviño)
TestLauncher: add unit test to check the emission of the mouse_enter signal |
200 |
struct TestWindowCompositor |
201 |
{
|
|
202 |
static void SetMousePosition(int x, int y) |
|
203 |
{
|
|
204 |
nux::GetWindowCompositor()._mouse_position = nux::Point(x, y); |
|
205 |
}
|
|
206 |
};
|
|
207 |
||
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
208 |
TEST_F(TestLauncher, TestQuirksDuringDnd) |
209 |
{
|
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
210 |
MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon::Nice); |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
211 |
model_->AddIcon(first); |
212 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
213 |
MockMockLauncherIcon::Ptr second(new MockMockLauncherIcon::Nice); |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
214 |
model_->AddIcon(second); |
215 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
216 |
MockMockLauncherIcon::Ptr third(new MockMockLauncherIcon::Nice); |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
217 |
model_->AddIcon(third); |
218 |
||
219 |
EXPECT_CALL(*first, ShouldHighlightOnDrag(_)) |
|
220 |
.WillRepeatedly(Return(true)); |
|
221 |
||
222 |
EXPECT_CALL(*second, ShouldHighlightOnDrag(_)) |
|
223 |
.WillRepeatedly(Return(true)); |
|
224 |
||
225 |
EXPECT_CALL(*third, ShouldHighlightOnDrag(_)) |
|
226 |
.WillRepeatedly(Return(false)); |
|
227 |
||
2898.4.7
by Andrea Azzarone
Use the new classes in real code. |
228 |
launcher_->DndStarted(""); |
2497.2.1
by Andrea Azzarone
Add unit test for branch lp:~andyrock/unity/fix-1020891 |
229 |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
230 |
EXPECT_FALSE(first->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
231 |
EXPECT_FALSE(second->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
232 |
EXPECT_TRUE(third->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
233 |
}
|
234 |
||
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
235 |
TEST_F(TestLauncher, TestMouseWheelScroll) |
236 |
{
|
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
237 |
MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon::Nice); |
3096.5.2
by Andrea Azzarone
Add a test to be sure ::PerformScroll is called. |
238 |
model_->AddIcon(icon); |
239 |
||
240 |
launcher_->SetHover(true); |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
241 |
launcher_->icon_under_mouse_ = icon; |
3096.5.2
by Andrea Azzarone
Add a test to be sure ::PerformScroll is called. |
242 |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
243 |
unsigned long key_flags = 0; |
3096.5.2
by Andrea Azzarone
Add a test to be sure ::PerformScroll is called. |
244 |
|
245 |
EXPECT_CALL(*icon, PerformScroll(AbstractLauncherIcon::ScrollDirection::UP, _)); |
|
246 |
launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags); |
|
247 |
||
248 |
EXPECT_CALL(*icon, PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, _)); |
|
249 |
launcher_->RecvMouseWheel(0, 0, -20, 0, key_flags); |
|
250 |
||
251 |
launcher_->SetHover(false); |
|
252 |
}
|
|
253 |
||
254 |
TEST_F(TestLauncher, TestMouseWheelScrollAltPressed) |
|
255 |
{
|
|
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
256 |
int initial_scroll_delta; |
257 |
||
2540.11.3
by Bilal Akhtar
Fix tests |
258 |
launcher_->SetHover(true); |
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
259 |
initial_scroll_delta = launcher_->GetDragDelta(); |
260 |
||
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
261 |
unsigned long key_flags = 0; |
3096.4.1
by Andrea Azzarone
Scroll launcher only on alt + mouse wheel. |
262 |
|
263 |
launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags); |
|
264 |
EXPECT_EQ((launcher_->GetDragDelta()), initial_scroll_delta); |
|
265 |
||
266 |
key_flags |= nux::NUX_STATE_ALT; |
|
267 |
||
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
268 |
// scroll down
|
3096.4.1
by Andrea Azzarone
Scroll launcher only on alt + mouse wheel. |
269 |
launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags); |
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
270 |
EXPECT_EQ((launcher_->GetDragDelta() - initial_scroll_delta), 25); |
271 |
||
3096.5.2
by Andrea Azzarone
Add a test to be sure ::PerformScroll is called. |
272 |
// scroll up - alt pressed
|
3096.4.1
by Andrea Azzarone
Scroll launcher only on alt + mouse wheel. |
273 |
launcher_->RecvMouseWheel(0, 0, -20, 0, key_flags); |
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
274 |
EXPECT_EQ(launcher_->GetDragDelta(), initial_scroll_delta); |
2540.11.3
by Bilal Akhtar
Fix tests |
275 |
|
276 |
launcher_->SetHover(false); |
|
2540.11.2
by Bilal Akhtar
Add unit test, doesn't seem to work as of now |
277 |
}
|
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
278 |
|
279 |
TEST_F(TestLauncher, TestIconBackgroundIntensity) |
|
280 |
{
|
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
281 |
MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon::Nice); |
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
282 |
model_->AddIcon(first); |
283 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
284 |
MockMockLauncherIcon::Ptr second(new MockMockLauncherIcon::Nice); |
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
285 |
model_->AddIcon(second); |
286 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
287 |
MockMockLauncherIcon::Ptr third(new MockMockLauncherIcon::Nice); |
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
288 |
model_->AddIcon(third); |
289 |
||
290 |
options_->backlight_mode = BACKLIGHT_NORMAL; |
|
291 |
options_->launch_animation = LAUNCH_ANIMATION_PULSE; |
|
292 |
||
2540.4.4
by Andrea Azzarone
Merge trunk. |
293 |
first->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, true); |
294 |
second->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, true); |
|
295 |
third->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, false); |
|
2540.4.3
by Andrea Azzarone
Add a test for IconBackgroundItensity with the default option value for backlight mode and start animation. |
296 |
|
297 |
Utils::WaitForTimeoutMSec(STARTING_ANIMATION_DURATION); |
|
298 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
299 |
EXPECT_THAT(launcher_->IconBackgroundIntensity(first), Gt(0.0f)); |
300 |
EXPECT_THAT(launcher_->IconBackgroundIntensity(second), Gt(0.0f)); |
|
301 |
EXPECT_EQ(launcher_->IconBackgroundIntensity(third), 0.0f); |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
302 |
}
|
303 |
||
2641.1.20
by Marco Trevisan (Treviño)
TestLauncher: rename test |
304 |
TEST_F(TestLauncher, DragLauncherIconCancelRestoresIconOrder) |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
305 |
{
|
2529.14.56
by Marco Trevisan (Treviño)
TestLauncher: add AddMockIcons utility function |
306 |
auto const& icons = AddMockIcons(3); |
307 |
||
308 |
auto const& icon1 = icons[0]; |
|
309 |
auto const& icon2 = icons[1]; |
|
310 |
auto const& icon3 = icons[2]; |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
311 |
|
312 |
// Start dragging icon2
|
|
313 |
launcher_->StartIconDrag(icon2); |
|
314 |
launcher_->ShowDragWindow(); |
|
315 |
||
316 |
// Moving icon2 at the end
|
|
317 |
auto const& center3 = icon3->GetCenter(launcher_->monitor()); |
|
318 |
launcher_->UpdateDragWindowPosition(center3.x, center3.y); |
|
319 |
||
320 |
auto it = model_->begin(); |
|
2641.1.16
by Marco Trevisan (Treviño)
tests: updated to add HideDragWindow() |
321 |
ASSERT_EQ(*it, icon1); it++; |
322 |
ASSERT_EQ(*it, icon3); it++; |
|
323 |
ASSERT_EQ(*it, icon2); |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
324 |
|
325 |
// Moving icon2 at the begin
|
|
326 |
auto const& center1 = icon1->GetCenter(launcher_->monitor()); |
|
327 |
launcher_->UpdateDragWindowPosition(center1.x, center1.y); |
|
328 |
||
329 |
it = model_->begin(); |
|
2641.1.16
by Marco Trevisan (Treviño)
tests: updated to add HideDragWindow() |
330 |
ASSERT_EQ(*it, icon2); it++; |
331 |
ASSERT_EQ(*it, icon1); it++; |
|
332 |
ASSERT_EQ(*it, icon3); |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
333 |
|
334 |
bool model_saved = false; |
|
335 |
model_->saved.connect([&model_saved] { model_saved = true; }); |
|
336 |
||
337 |
// Emitting the drag cancel request
|
|
338 |
launcher_->GetDraggedIcon()->drag_cancel_request.emit(); |
|
3494.5.12
by Marco Trevisan (Treviño)
TestLauncher: verify that the correct action state is set on drag cancel |
339 |
EXPECT_TRUE(launcher_->IsActionStateDragCancelled()); |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
340 |
|
341 |
// The icon order should be reset
|
|
342 |
it = model_->begin(); |
|
2641.1.16
by Marco Trevisan (Treviño)
tests: updated to add HideDragWindow() |
343 |
ASSERT_EQ(*it, icon1); it++; |
344 |
ASSERT_EQ(*it, icon2); it++; |
|
345 |
ASSERT_EQ(*it, icon3); |
|
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
346 |
|
347 |
EXPECT_FALSE(model_saved); |
|
2641.1.16
by Marco Trevisan (Treviño)
tests: updated to add HideDragWindow() |
348 |
|
349 |
launcher_->HideDragWindow(); |
|
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
350 |
|
351 |
// Let's wait the drag icon animation to be completed
|
|
3440.1.45
by Marco Trevisan (Treviño)
TestLauncher: use WaitPendingEvents instead of a fixed timeout |
352 |
Utils::WaitPendingEvents(); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
353 |
EXPECT_EQ(launcher_->GetDraggedIcon(), nullptr); |
354 |
}
|
|
355 |
||
356 |
TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged) |
|
357 |
{
|
|
358 |
auto const& icons = AddMockIcons(3); |
|
359 |
||
360 |
auto const& icon1 = icons[0]; |
|
361 |
auto const& icon2 = icons[1]; |
|
362 |
auto const& icon3 = icons[2]; |
|
363 |
||
364 |
// Start dragging icon2
|
|
365 |
launcher_->StartIconDrag(icon2); |
|
366 |
launcher_->ShowDragWindow(); |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
367 |
ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2)); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
368 |
|
369 |
// Moving icon2 at the end
|
|
370 |
auto const& center3 = icon3->GetCenter(launcher_->monitor()); |
|
371 |
launcher_->UpdateDragWindowPosition(center3.x, center3.y); |
|
372 |
||
3477.6.23
by Marco Trevisan (Treviño)
Launcher: stick and save icons dragged around |
373 |
EXPECT_CALL(*icon2, Stick(true)); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
374 |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
375 |
ASSERT_NE(launcher_->drag_icon_position_, model_->IconIndex(icon2)); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
376 |
launcher_->EndIconDrag(); |
377 |
||
378 |
// The icon order should be reset
|
|
379 |
auto it = model_->begin(); |
|
380 |
ASSERT_EQ(*it, icon1); it++; |
|
381 |
ASSERT_EQ(*it, icon3); it++; |
|
382 |
ASSERT_EQ(*it, icon2); |
|
383 |
||
384 |
// Let's wait the drag icon animation to be completed
|
|
3440.1.46
by Marco Trevisan (Treviño)
TestLauncher: Use WaitUntilMSec with lambda body to ensure dragged window is deleted |
385 |
Utils::WaitUntilMSec([this] { return launcher_->GetDraggedIcon(); }, false, 2000); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
386 |
EXPECT_EQ(launcher_->GetDraggedIcon(), nullptr); |
387 |
}
|
|
388 |
||
389 |
TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged) |
|
390 |
{
|
|
391 |
auto const& icons = AddMockIcons(3); |
|
392 |
||
393 |
auto const& icon1 = icons[0]; |
|
394 |
auto const& icon2 = icons[1]; |
|
395 |
auto const& icon3 = icons[2]; |
|
396 |
||
397 |
// Start dragging icon2
|
|
398 |
launcher_->StartIconDrag(icon2); |
|
399 |
launcher_->ShowDragWindow(); |
|
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
400 |
ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2)); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
401 |
|
402 |
// Moving icon2 at the end
|
|
403 |
auto center3 = icon3->GetCenter(launcher_->monitor()); |
|
404 |
launcher_->UpdateDragWindowPosition(center3.x, center3.y); |
|
405 |
||
406 |
// Swapping the centers
|
|
3536.3.22
by Marco Trevisan (Treviño)
LauncherIcon: don't save parent geometries anymore, SetCenter should now include them |
407 |
icon3->SetCenter(icon2->GetCenter(launcher_->monitor()), launcher_->monitor()); |
408 |
icon2->SetCenter(center3, launcher_->monitor()); |
|
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
409 |
|
410 |
// Moving icon2 back to the middle
|
|
411 |
center3 = icon3->GetCenter(launcher_->monitor()); |
|
412 |
launcher_->UpdateDragWindowPosition(center3.x, center3.y); |
|
413 |
||
414 |
bool model_saved = false; |
|
415 |
model_->saved.connect([&model_saved] { model_saved = true; }); |
|
416 |
||
3494.8.1
by Marco Trevisan (Treviño)
Launcher: fix style to use postfixed-underscore for private members |
417 |
ASSERT_EQ(launcher_->drag_icon_position_, model_->IconIndex(icon2)); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
418 |
launcher_->EndIconDrag(); |
419 |
||
420 |
// The icon order should be reset
|
|
421 |
auto it = model_->begin(); |
|
422 |
ASSERT_EQ(*it, icon1); it++; |
|
423 |
ASSERT_EQ(*it, icon2); it++; |
|
424 |
ASSERT_EQ(*it, icon3); |
|
425 |
||
426 |
EXPECT_FALSE(model_saved); |
|
427 |
||
428 |
// Let's wait the drag icon animation to be completed
|
|
3440.1.46
by Marco Trevisan (Treviño)
TestLauncher: Use WaitUntilMSec with lambda body to ensure dragged window is deleted |
429 |
Utils::WaitUntilMSec([this] { return launcher_->GetDraggedIcon(); }, false, 2000); |
2529.14.60
by Marco Trevisan (Treviño)
TestLauncher: add test to check drag icon when setting an icon back to its position |
430 |
EXPECT_EQ(launcher_->GetDraggedIcon(), nullptr); |
2641.1.12
by Marco Trevisan (Treviño)
tests, TestLauncher: add a tests to verify that the icon order is restored when cancelling an icon drag |
431 |
}
|
432 |
||
2816.2.2
by Marco Trevisan (Treviño)
TestLauncher: added stick-on-drag tests |
433 |
TEST_F(TestLauncher, DragLauncherIconSticksApplicationIcon) |
434 |
{
|
|
435 |
auto const& icons = AddMockIcons(1); |
|
436 |
||
437 |
MockMockLauncherIcon::Ptr app(new MockMockLauncherIcon(AbstractLauncherIcon::IconType::APPLICATION)); |
|
438 |
model_->AddIcon(app); |
|
439 |
||
440 |
// Start dragging app icon
|
|
441 |
launcher_->StartIconDrag(app); |
|
442 |
launcher_->ShowDragWindow(); |
|
443 |
||
444 |
// Moving app icon to the beginning
|
|
445 |
auto const& center = icons[0]->GetCenter(launcher_->monitor()); |
|
446 |
launcher_->UpdateDragWindowPosition(center.x, center.y); |
|
447 |
||
3477.6.23
by Marco Trevisan (Treviño)
Launcher: stick and save icons dragged around |
448 |
EXPECT_CALL(*app, Stick(true)); |
2816.2.2
by Marco Trevisan (Treviño)
TestLauncher: added stick-on-drag tests |
449 |
launcher_->EndIconDrag(); |
450 |
}
|
|
451 |
||
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
452 |
TEST_F(TestLauncher, DragLauncherIconSticksDeviceIcon) |
453 |
{
|
|
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
454 |
auto const& icons = AddMockIcons(1); |
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
455 |
|
456 |
MockMockLauncherIcon::Ptr device(new MockMockLauncherIcon(AbstractLauncherIcon::IconType::DEVICE)); |
|
457 |
model_->AddIcon(device); |
|
458 |
||
459 |
// Start dragging device icon
|
|
460 |
launcher_->StartIconDrag(device); |
|
461 |
launcher_->ShowDragWindow(); |
|
462 |
||
463 |
// Moving device icon to the beginning
|
|
464 |
auto const& center = icons[0]->GetCenter(launcher_->monitor()); |
|
465 |
launcher_->UpdateDragWindowPosition(center.x, center.y); |
|
466 |
||
3477.6.23
by Marco Trevisan (Treviño)
Launcher: stick and save icons dragged around |
467 |
EXPECT_CALL(*device, Stick(true)); |
2529.14.61
by Marco Trevisan (Treviño)
TestLauncher: check if a device icon is sticked when dragged. |
468 |
launcher_->EndIconDrag(); |
469 |
}
|
|
470 |
||
2740.3.2
by Marco Trevisan (Treviño)
TestLauncher: add unit test to check the emission of the mouse_enter signal |
471 |
TEST_F(TestLauncher, DragLauncherIconHidesOverLauncherEmitsMouseEnter) |
472 |
{
|
|
473 |
bool mouse_entered = false; |
|
474 |
||
475 |
launcher_->mouse_enter.connect([&mouse_entered] (int x, int y, unsigned long, unsigned long) { |
|
476 |
mouse_entered = true; |
|
477 |
EXPECT_EQ(x, 1); |
|
478 |
EXPECT_EQ(y, 2); |
|
479 |
});
|
|
480 |
||
481 |
auto const& abs_geo = launcher_->GetAbsoluteGeometry(); |
|
482 |
TestWindowCompositor::SetMousePosition(abs_geo.x + 1, abs_geo.y + 2); |
|
483 |
launcher_->HideDragWindow(); |
|
484 |
EXPECT_TRUE(mouse_entered); |
|
485 |
}
|
|
486 |
||
487 |
TEST_F(TestLauncher, DragLauncherIconHidesOutsideLauncherEmitsMouseEnter) |
|
488 |
{
|
|
489 |
bool mouse_entered = false; |
|
490 |
launcher_->mouse_enter.connect([&mouse_entered] (int, int, unsigned long, unsigned long) |
|
491 |
{ mouse_entered = true; }); |
|
492 |
||
493 |
auto const& abs_geo = launcher_->GetAbsoluteGeometry(); |
|
494 |
TestWindowCompositor::SetMousePosition(abs_geo.x - 1, abs_geo.y - 2); |
|
495 |
launcher_->HideDragWindow(); |
|
496 |
EXPECT_FALSE(mouse_entered); |
|
497 |
}
|
|
498 |
||
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
499 |
TEST_F(TestLauncher, EdgeReleasesDuringDnd) |
2926.2.3
by Andrea Azzarone
Add tests. |
500 |
{
|
3129.1.6
by Marco Trevisan (Treviño)
TestEdgeBarrierController / TestLauncher: fix tests against new API |
501 |
auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); |
2926.2.3
by Andrea Azzarone
Add tests. |
502 |
auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); |
503 |
||
2926.2.4
by Andrea Azzarone
Merge trunk. |
504 |
launcher_->DndStarted(""); |
2926.2.3
by Andrea Azzarone
Add tests. |
505 |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
506 |
EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.6
by Marco Trevisan (Treviño)
TestEdgeBarrierController / TestLauncher: fix tests against new API |
507 |
ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE); |
2926.2.3
by Andrea Azzarone
Add tests. |
508 |
}
|
509 |
||
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
510 |
TEST_F(TestLauncher, EdgeBarriersIgnoreEvents) |
511 |
{
|
|
512 |
auto const& launcher_geo = launcher_->GetAbsoluteGeometry(); |
|
513 |
auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); |
|
514 |
auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); |
|
515 |
launcher_->SetHidden(true); |
|
516 |
||
517 |
event->x = launcher_geo.x-1; |
|
518 |
event->y = launcher_geo.y; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
519 |
EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
520 |
ui::EdgeBarrierSubscriber::Result::IGNORED); |
521 |
||
522 |
event->x = launcher_geo.x+launcher_geo.width+1; |
|
523 |
event->y = launcher_geo.y; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
524 |
EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
525 |
ui::EdgeBarrierSubscriber::Result::IGNORED); |
526 |
||
527 |
options_->reveal_trigger = RevealTrigger::EDGE; |
|
528 |
event->x = launcher_geo.x+launcher_geo.width/2; |
|
529 |
event->y = launcher_geo.y - 1; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
530 |
EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
531 |
ui::EdgeBarrierSubscriber::Result::IGNORED); |
532 |
||
533 |
options_->reveal_trigger = RevealTrigger::CORNER; |
|
534 |
event->x = launcher_geo.x+launcher_geo.width/2; |
|
535 |
event->y = launcher_geo.y; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
536 |
EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
537 |
ui::EdgeBarrierSubscriber::Result::IGNORED); |
538 |
}
|
|
539 |
||
540 |
TEST_F(TestLauncher, EdgeBarriersHandlesEvent) |
|
541 |
{
|
|
3999.7.18
by handsome_feng
move the launcher-position from com.canonical.Unity to com.canonical.Unity.Launcher |
542 |
glib::Object<GSettings> gsettings(g_settings_new("com.canonical.Unity.Launcher")); |
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
543 |
auto launcher_geo = launcher_->GetAbsoluteGeometry(); |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
544 |
auto barrier = std::make_shared<ui::PointerBarrierWrapper>(); |
545 |
auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100); |
|
546 |
launcher_->SetHidden(true); |
|
547 |
||
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
548 |
g_settings_set_enum(gsettings, "launcher-position", static_cast<int>(LauncherPosition::LEFT)); |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
549 |
options_->reveal_trigger = RevealTrigger::EDGE; |
550 |
||
551 |
for (int x = launcher_geo.x; x < launcher_geo.x+launcher_geo.width; ++x) |
|
552 |
{
|
|
553 |
for (int y = launcher_geo.y; y < launcher_geo.y+launcher_geo.height; ++y) |
|
554 |
{
|
|
555 |
event->x = x; |
|
556 |
event->y = y; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
557 |
ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
558 |
ui::EdgeBarrierSubscriber::Result::HANDLED); |
559 |
}
|
|
560 |
}
|
|
561 |
||
562 |
options_->reveal_trigger = RevealTrigger::CORNER; |
|
563 |
||
564 |
for (int x = launcher_geo.x; x < launcher_geo.x+launcher_geo.width; ++x) |
|
565 |
{
|
|
566 |
for (int y = launcher_geo.y-10; y < launcher_geo.y; ++y) |
|
567 |
{
|
|
568 |
event->x = x; |
|
569 |
event->y = y; |
|
3893.6.1
by Andrea Azzarone
Use a weak_ptr to avoid crashes. |
570 |
ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
571 |
ui::EdgeBarrierSubscriber::Result::HANDLED); |
572 |
}
|
|
573 |
}
|
|
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
574 |
|
575 |
g_settings_set_enum(gsettings, "launcher-position", static_cast<int>(LauncherPosition::BOTTOM)); |
|
576 |
launcher_geo = launcher_->GetAbsoluteGeometry(); |
|
577 |
options_->reveal_trigger = RevealTrigger::EDGE; |
|
3999.7.19
by handsome_feng
fix the error in test_launcher.cpp |
578 |
int panel_height = panel::Style::Instance().PanelHeight(launcher_->monitor()); |
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
579 |
|
580 |
for (int y = launcher_geo.y; y < launcher_geo.y+launcher_geo.height; ++y) |
|
581 |
{
|
|
3999.7.19
by handsome_feng
fix the error in test_launcher.cpp |
582 |
for (int x = launcher_geo.x + panel_height; x < launcher_geo.x+launcher_geo.width; ++x) |
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
583 |
{
|
584 |
event->x = x; |
|
585 |
event->y = y; |
|
586 |
ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
|
587 |
ui::EdgeBarrierSubscriber::Result::HANDLED); |
|
588 |
}
|
|
589 |
}
|
|
590 |
||
591 |
options_->reveal_trigger = RevealTrigger::CORNER; |
|
592 |
||
593 |
for (int y = launcher_geo.y; y < launcher_geo.y+launcher_geo.height; ++y) |
|
594 |
{
|
|
3999.7.19
by handsome_feng
fix the error in test_launcher.cpp |
595 |
for (int x = launcher_geo.x; x < launcher_geo.x + panel_height; ++x) |
3999.7.7
by handsome_feng
modified some test, added the indicator icon, and fix some bug |
596 |
{
|
597 |
event->x = x; |
|
598 |
event->y = y; |
|
599 |
ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event), |
|
600 |
ui::EdgeBarrierSubscriber::Result::HANDLED); |
|
601 |
}
|
|
602 |
}
|
|
603 |
||
604 |
g_settings_reset(gsettings, "launcher-position"); |
|
3129.1.7
by Marco Trevisan (Treviño)
TestLauncher: add more edge subscriber tests |
605 |
}
|
606 |
||
2529.14.62
by Marco Trevisan (Treviño)
TestLauncher: add test for DndIsSpecialRequest |
607 |
TEST_F(TestLauncher, DndIsSpecialRequest) |
608 |
{
|
|
609 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("MyFile.desktop")); |
|
610 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("/full/path/to/MyFile.desktop")); |
|
611 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("application://MyFile.desktop")); |
|
612 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("file://MyFile.desktop")); |
|
613 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("file://full/path/to/MyFile.desktop")); |
|
614 |
EXPECT_TRUE(launcher_->DndIsSpecialRequest("device://uuuid")); |
|
615 |
||
616 |
EXPECT_FALSE(launcher_->DndIsSpecialRequest("MyFile.txt")); |
|
617 |
EXPECT_FALSE(launcher_->DndIsSpecialRequest("/full/path/to/MyFile.txt")); |
|
618 |
EXPECT_FALSE(launcher_->DndIsSpecialRequest("file://full/path/to/MyFile.txt")); |
|
619 |
}
|
|
620 |
||
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
621 |
TEST_F(TestLauncher, AddRequestSignal) |
622 |
{
|
|
623 |
auto const& icons = AddMockIcons(1); |
|
624 |
auto const& center = icons[0]->GetCenter(launcher_->monitor()); |
|
625 |
launcher_->ProcessDndEnter(); |
|
626 |
launcher_->FakeProcessDndMove(center.x, center.y, {"application://MyFile.desktop"}); |
|
627 |
||
628 |
bool add_request = false; |
|
629 |
launcher_->add_request.connect([&] (std::string const& uri, AbstractLauncherIcon::Ptr const& drop_icon) { |
|
630 |
EXPECT_EQ(drop_icon, icons[0]); |
|
631 |
EXPECT_EQ(uri, "application://MyFile.desktop"); |
|
632 |
add_request = true; |
|
633 |
});
|
|
634 |
||
635 |
launcher_->ProcessDndDrop(center.x, center.y); |
|
636 |
launcher_->ProcessDndLeave(); |
|
637 |
||
638 |
EXPECT_TRUE(add_request); |
|
639 |
}
|
|
640 |
||
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
641 |
TEST_F(TestLauncher, IconStartingPulseValue) |
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
642 |
{
|
643 |
MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon::Nice); |
|
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
644 |
|
645 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true); |
|
646 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
647 |
// Pulse value should start at 1.
|
648 |
EXPECT_FLOAT_EQ(launcher_->IconStartingPulseValue(icon), 1.0); |
|
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
649 |
}
|
650 |
||
651 |
TEST_F(TestLauncher, IconStartingBlinkValue) |
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
652 |
{
|
653 |
MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon::Nice); |
|
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
654 |
|
655 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true); |
|
656 |
||
657 |
// Pulse value should start at 0.
|
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
658 |
EXPECT_FLOAT_EQ(launcher_->IconStartingBlinkValue(icon), 1.0); |
2866.6.2
by Nick Dedekind
Added launcher icon blink/pulse test. |
659 |
}
|
2529.14.64
by Marco Trevisan (Treviño)
TestLauncher: addtest for add_request signal |
660 |
|
3264.2.2
by Brandon Schaefer
* Now if there are no Uris, we ignore checking if we should dim them launcher |
661 |
TEST_F(TestLauncher, HighlightingEmptyUrisOnDragMoveIsIgnored) |
3256.1.1
by Brandon Schaefer
* If a ProcessDndLeave happens check if we are in an External Drag state |
662 |
{
|
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
663 |
MockMockLauncherIcon::Ptr first(new MockMockLauncherIcon::Nice); |
3264.2.1
by Brandon Schaefer
* If no Uris are found while doing a ProcessDndMove desaturate all the icons, |
664 |
model_->AddIcon(first); |
665 |
||
3264.2.2
by Brandon Schaefer
* Now if there are no Uris, we ignore checking if we should dim them launcher |
666 |
EXPECT_CALL(*first, ShouldHighlightOnDrag(_)).Times(0); |
3264.2.1
by Brandon Schaefer
* If no Uris are found while doing a ProcessDndMove desaturate all the icons, |
667 |
launcher_->ProcessDndMove(0,0,{}); |
3256.1.1
by Brandon Schaefer
* If a ProcessDndLeave happens check if we are in an External Drag state |
668 |
}
|
669 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
670 |
TEST_F(TestLauncher, UrgentIconTimerStart) |
671 |
{
|
|
672 |
auto icon = AddMockIcons(1).front(); |
|
673 |
launcher_->SetHidden(true); |
|
674 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
675 |
ASSERT_THAT(launcher_->sources_.GetSource("urgent-timeout"), IsNull()); |
|
676 |
ASSERT_TRUE(launcher_->animating_urgent_icons_.empty()); |
|
677 |
||
678 |
launcher_->HandleUrgentIcon(icon); |
|
679 |
EXPECT_THAT(launcher_->sources_.GetSource("urgent-timeout"), NotNull()); |
|
680 |
ASSERT_EQ(std::set<AbstractLauncherIcon::Ptr>({icon}), launcher_->animating_urgent_icons_); |
|
681 |
}
|
|
682 |
||
683 |
TEST_F(TestLauncher, UrgentIconSaved) |
|
684 |
{
|
|
685 |
auto icon = AddMockIcons(1).front(); |
|
686 |
launcher_->SetHidden(true); |
|
687 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
688 |
ASSERT_TRUE(launcher_->animating_urgent_icons_.empty()); |
|
689 |
||
690 |
launcher_->HandleUrgentIcon(icon); |
|
691 |
ASSERT_EQ(std::set<AbstractLauncherIcon::Ptr>({icon}), launcher_->animating_urgent_icons_); |
|
692 |
}
|
|
693 |
||
694 |
TEST_F(TestLauncher, UrgentIconIsHandled) |
|
695 |
{
|
|
696 |
auto icon = AddMockIcons(1).front(); |
|
697 |
launcher_->SetHidden(true); |
|
698 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
699 |
ASSERT_TRUE(launcher_->animating_urgent_icons_.empty()); |
|
700 |
||
701 |
launcher_->HandleUrgentIcon(icon); |
|
702 |
ASSERT_EQ(std::set<AbstractLauncherIcon::Ptr>({icon}), launcher_->animating_urgent_icons_); |
|
703 |
}
|
|
704 |
||
3566.4.14
by Marco Trevisan (Treviño)
TestLauncher: add one more test about urgent icons handling (on autohide) |
705 |
TEST_F(TestLauncher, UrgentIconsUnhandling) |
706 |
{
|
|
707 |
auto icons = AddMockIcons(2); |
|
708 |
launcher_->SetHidden(true); |
|
709 |
||
710 |
for (auto const& icon : icons) |
|
711 |
{
|
|
712 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
713 |
launcher_->HandleUrgentIcon(icon); |
|
714 |
}
|
|
715 |
||
716 |
ASSERT_FALSE(launcher_->animating_urgent_icons_.empty()); |
|
717 |
ASSERT_THAT(launcher_->sources_.GetSource("urgent-timeout"), NotNull()); |
|
718 |
||
719 |
icons[0]->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false); |
|
720 |
launcher_->HandleUrgentIcon(icons[0]); |
|
721 |
||
722 |
ASSERT_EQ(std::set<AbstractLauncherIcon::Ptr>({icons[1]}), launcher_->animating_urgent_icons_); |
|
723 |
EXPECT_THAT(launcher_->sources_.GetSource("urgent-timeout"), NotNull()); |
|
724 |
||
725 |
icons[1]->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false); |
|
726 |
launcher_->HandleUrgentIcon(icons[1]); |
|
727 |
EXPECT_TRUE(launcher_->animating_urgent_icons_.empty()); |
|
728 |
EXPECT_THAT(launcher_->sources_.GetSource("urgent-timeout"), IsNull()); |
|
729 |
}
|
|
730 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
731 |
TEST_F(TestLauncher, UrgentIconTimerTimeout) |
732 |
{
|
|
733 |
auto icons = AddMockIcons(5); |
|
734 |
launcher_->SetHidden(true); |
|
735 |
||
736 |
for (unsigned i = 0; i < icons.size(); ++i) |
|
737 |
{
|
|
738 |
bool urgent = ((i % 2) == 0); |
|
739 |
icons[i]->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, urgent); |
|
740 |
||
741 |
InSequence seq; |
|
742 |
EXPECT_CALL(*icons[i], SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
743 |
EXPECT_CALL(*icons[i], SkipQuirkAnimation(AbstractLauncherIcon::Quirk::URGENT, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
744 |
EXPECT_CALL(*icons[i], SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
745 |
}
|
|
746 |
||
747 |
ASSERT_EQ(launcher_->urgent_animation_period_, 0); |
|
748 |
||
749 |
// Simulate timer call
|
|
750 |
ASSERT_FALSE(launcher_->OnUrgentTimeout()); |
|
751 |
||
752 |
EXPECT_THAT(launcher_->urgent_animation_period_, Gt(0)); |
|
753 |
EXPECT_THAT(launcher_->sources_.GetSource("urgent-timeout"), NotNull()); |
|
754 |
}
|
|
755 |
||
3611.1.2
by Chris Townsend
Add new unit test to test the condition for this bug. |
756 |
TEST_F(TestLauncher, UrgentIconTimerReset) |
757 |
{
|
|
758 |
auto icon = AddMockIcons(1).front(); |
|
759 |
launcher_->SetHidden(true); |
|
760 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
761 |
ASSERT_EQ(launcher_->urgent_animation_period_, 0); |
|
762 |
||
763 |
launcher_->HandleUrgentIcon(icon); |
|
764 |
launcher_->OnUrgentTimeout(); |
|
765 |
||
766 |
ASSERT_THAT(launcher_->urgent_animation_period_, Gt(0)); |
|
767 |
||
768 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false); |
|
769 |
launcher_->HandleUrgentIcon(icon); |
|
770 |
||
771 |
icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true); |
|
772 |
launcher_->HandleUrgentIcon(icon); |
|
773 |
||
774 |
EXPECT_EQ(launcher_->urgent_animation_period_, 0); |
|
775 |
}
|
|
776 |
||
777 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
778 |
TEST_F(TestLauncher, UrgentIconsAnimateAfterLauncherIsRevealed) |
779 |
{
|
|
780 |
auto icons = AddMockIcons(5); |
|
781 |
launcher_->SetHidden(true); |
|
782 |
||
783 |
for (unsigned i = 0; i < icons.size(); ++i) |
|
784 |
{
|
|
785 |
icons[i]->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, (i % 2) == 0); |
|
786 |
EXPECT_CALL(*icons[i], SetQuirk(AbstractLauncherIcon::Quirk::URGENT, _, _)).Times(0); |
|
787 |
launcher_->HandleUrgentIcon(icons[i]); |
|
788 |
}
|
|
3320.1.9
by Chris Townsend
* Change some EXPECT_* to ASSERT_* since we don't want to continue the test if the prerequisite fails. |
789 |
|
790 |
launcher_->SetHidden(false); |
|
791 |
||
3566.4.10
by Marco Trevisan (Treviño)
LauncherIcon: use nux::Animation for each Quirk property |
792 |
for (auto const& icon : icons) |
793 |
{
|
|
794 |
Mock::VerifyAndClearExpectations(icon.GetPointer()); |
|
795 |
bool urgent = icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, launcher_->monitor()); |
|
796 |
||
797 |
InSequence seq; |
|
798 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
799 |
EXPECT_CALL(*icon, SkipQuirkAnimation(AbstractLauncherIcon::Quirk::URGENT, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
800 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true, launcher_->monitor())).Times(urgent ? 1 : 0); |
|
801 |
||
802 |
launcher_->HandleUrgentIcon(icon); |
|
803 |
}
|
|
804 |
||
805 |
Utils::WaitPendingEvents(); |
|
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
806 |
}
|
807 |
||
3566.4.21
by Marco Trevisan (Treviño)
TestLauncher: add IsOverlayOpen tests |
808 |
TEST_F(TestLauncher, IsOverlayOpen) |
809 |
{
|
|
810 |
EXPECT_FALSE(launcher_->IsOverlayOpen()); |
|
811 |
}
|
|
812 |
||
813 |
TEST_F(TestLauncher, IsOverlayOpenDash) |
|
814 |
{
|
|
815 |
GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, launcher_->monitor(), 0, 0); |
|
816 |
UBusManager().SendMessage(UBUS_OVERLAY_SHOWN, info); |
|
817 |
Utils::WaitUntilMSec([this] { return launcher_->IsOverlayOpen(); }); |
|
818 |
EXPECT_TRUE(launcher_->IsOverlayOpen()); |
|
819 |
}
|
|
820 |
||
821 |
TEST_F(TestLauncher, IsOverlayOpenHud) |
|
822 |
{
|
|
823 |
GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", TRUE, launcher_->monitor(), 0, 0); |
|
824 |
UBusManager().SendMessage(UBUS_OVERLAY_SHOWN, info); |
|
825 |
Utils::WaitUntilMSec([this] { return launcher_->IsOverlayOpen(); }); |
|
826 |
EXPECT_TRUE(launcher_->IsOverlayOpen()); |
|
827 |
}
|
|
828 |
||
829 |
TEST_F(TestLauncher, IsOverlayOpenSpread) |
|
830 |
{
|
|
831 |
WM->SetScaleActive(true); |
|
832 |
EXPECT_TRUE(launcher_->IsOverlayOpen()); |
|
833 |
}
|
|
834 |
||
3566.4.22
by Marco Trevisan (Treviño)
Launcher: desaturate icons when in Expo mode as well |
835 |
TEST_F(TestLauncher, IsOverlayOpenExpo) |
836 |
{
|
|
837 |
WM->SetExpoActive(true); |
|
838 |
EXPECT_TRUE(launcher_->IsOverlayOpen()); |
|
839 |
}
|
|
840 |
||
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
841 |
TEST_F(TestLauncher, DesaturateAllIconsOnSpread) |
842 |
{
|
|
843 |
auto const& icons = AddMockIcons(5); |
|
844 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
845 |
||
846 |
WM->SetScaleActive(true); |
|
847 |
||
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
848 |
Utils::WaitUntilMSec([this, &icons] { |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
849 |
for (auto const& icon : icons) |
850 |
{
|
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
851 |
if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())) |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
852 |
return false; |
853 |
}
|
|
854 |
return true; |
|
855 |
});
|
|
856 |
||
857 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
858 |
{
|
859 |
for (int i = 0; i < static_cast<int>(monitors::MAX); ++i) |
|
860 |
ASSERT_EQ(launcher_->monitor() == i, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i)); |
|
861 |
}
|
|
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
862 |
}
|
863 |
||
864 |
TEST_F(TestLauncher, SaturateAllIconsOnSpreadTerminated) |
|
865 |
{
|
|
866 |
auto const& icons = AddMockIcons(5); |
|
867 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
868 |
||
869 |
for (auto const& icon : icons) |
|
3566.4.24
by Marco Trevisan (Treviño)
TestLauncher: verify saturation during Expo |
870 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
871 |
|
872 |
WM->terminate_spread.emit(); |
|
873 |
}
|
|
874 |
||
875 |
TEST_F(TestLauncher, SaturatesAllIconsOnSpreadWithMouseOver) |
|
876 |
{
|
|
877 |
auto const& icons = AddMockIcons(5); |
|
878 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
879 |
||
880 |
for (auto const& icon : icons) |
|
3566.4.24
by Marco Trevisan (Treviño)
TestLauncher: verify saturation during Expo |
881 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true, _)).Times(0); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
882 |
|
883 |
launcher_->SetHover(true); |
|
884 |
WM->SetScaleActive(true); |
|
885 |
||
886 |
Utils::WaitPendingEvents(); |
|
887 |
}
|
|
888 |
||
889 |
TEST_F(TestLauncher, DesaturateInactiveIconsOnAppSpread) |
|
890 |
{
|
|
891 |
auto const& icons = AddMockIcons(5); |
|
892 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
893 |
||
894 |
WM->SetScaleActiveForGroup(true); |
|
895 |
||
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
896 |
Utils::WaitUntilMSec([this, &icons] { |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
897 |
for (auto const& icon : icons) |
898 |
{
|
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
899 |
if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())) |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
900 |
return false; |
901 |
}
|
|
902 |
return true; |
|
903 |
});
|
|
904 |
||
905 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
906 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
907 |
}
|
908 |
||
909 |
TEST_F(TestLauncher, SaturatesAllIconsOnAppSpreadMouseMove) |
|
910 |
{
|
|
911 |
auto const& icons = AddMockIcons(5); |
|
912 |
unsigned active_idx = g_random_int()%icons.size(); |
|
913 |
icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
914 |
||
915 |
launcher_->SetHover(true); |
|
916 |
WM->SetScaleActiveForGroup(true); |
|
917 |
||
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
918 |
Utils::WaitUntilMSec([this, &icons] { |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
919 |
for (auto const& icon : icons) |
920 |
{
|
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
921 |
if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())) |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
922 |
return false; |
923 |
}
|
|
924 |
return true; |
|
925 |
});
|
|
926 |
||
927 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
928 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
929 |
|
930 |
auto const& active_center = icons[active_idx]->GetCenter(launcher_->monitor()); |
|
931 |
launcher_->mouse_move.emit(active_center.x, active_center.y, 0, 0, 0, 0); |
|
932 |
||
933 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
934 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
935 |
|
936 |
auto const& other_center = icons[(active_idx+1)%icons.size()]->GetCenter(launcher_->monitor()); |
|
937 |
launcher_->mouse_move.emit(other_center.x, other_center.y, 0, 0, 0, 0); |
|
938 |
||
939 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
940 |
ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
941 |
|
942 |
launcher_->SetHover(false); |
|
943 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
944 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
945 |
|
946 |
launcher_->SetHover(true); |
|
947 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
948 |
ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
949 |
}
|
950 |
||
951 |
TEST_F(TestLauncher, DesaturateActiveIconOnAppSpreadIconUpdate) |
|
952 |
{
|
|
953 |
auto const& icons = AddMockIcons(5); |
|
954 |
unsigned active_idx = g_random_int()%icons.size(); |
|
955 |
icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
956 |
||
957 |
launcher_->SetHover(true); |
|
958 |
WM->SetScaleActiveForGroup(true); |
|
959 |
||
960 |
Utils::WaitPendingEvents(); |
|
961 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
962 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
963 |
|
964 |
unsigned new_active_idx = (active_idx+1)%icons.size(); |
|
965 |
icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false); |
|
966 |
icons[new_active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
967 |
||
968 |
WM->terminate_spread.emit(); |
|
969 |
WM->initiate_spread.emit(); |
|
970 |
||
971 |
Utils::WaitPendingEvents(); |
|
972 |
for (auto const& icon : icons) |
|
3566.3.15
by Marco Trevisan (Treviño)
TestLauncher: use multi-monitor quirks |
973 |
ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
974 |
}
|
975 |
||
3566.4.24
by Marco Trevisan (Treviño)
TestLauncher: verify saturation during Expo |
976 |
TEST_F(TestLauncher, DesaturateAllIconsOnExpo) |
977 |
{
|
|
978 |
auto const& icons = AddMockIcons(5); |
|
979 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
980 |
||
981 |
WM->SetExpoActive(true); |
|
982 |
||
983 |
for (auto const& icon : icons) |
|
984 |
{
|
|
985 |
for (int i = 0; i < static_cast<int>(monitors::MAX); ++i) |
|
986 |
ASSERT_EQ(launcher_->monitor() == i, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i)); |
|
987 |
}
|
|
988 |
}
|
|
989 |
||
990 |
TEST_F(TestLauncher, SaturateAllIconsOnExpoTerminated) |
|
991 |
{
|
|
992 |
auto const& icons = AddMockIcons(5); |
|
993 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
994 |
||
995 |
for (auto const& icon : icons) |
|
996 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false, launcher_->monitor())); |
|
997 |
||
998 |
WM->terminate_expo.emit(); |
|
999 |
}
|
|
1000 |
||
1001 |
TEST_F(TestLauncher, SaturatesAllIconsOnExpoWithMouseOver) |
|
1002 |
{
|
|
1003 |
auto const& icons = AddMockIcons(5); |
|
1004 |
icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); |
|
1005 |
||
1006 |
for (auto const& icon : icons) |
|
1007 |
EXPECT_CALL(*icon, SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true, _)).Times(0); |
|
1008 |
||
1009 |
launcher_->SetHover(true); |
|
1010 |
WM->SetExpoActive(true); |
|
1011 |
}
|
|
1012 |
||
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
1013 |
TEST_F(TestLauncher, HideTooltipOnSpread) |
1014 |
{
|
|
1015 |
auto icon = AddMockIcons(1).front(); |
|
1016 |
EXPECT_CALL(*icon, HideTooltip()); |
|
1017 |
||
1018 |
launcher_->SetIconUnderMouse(icon); |
|
1019 |
WM->SetScaleActive(true); |
|
1020 |
}
|
|
1021 |
||
1022 |
TEST_F(TestLauncher, HideTooltipOnExpo) |
|
1023 |
{
|
|
1024 |
auto icon = AddMockIcons(1).front(); |
|
1025 |
EXPECT_CALL(*icon, HideTooltip()); |
|
1026 |
||
1027 |
launcher_->SetIconUnderMouse(icon); |
|
3566.3.30
by Marco Trevisan (Treviño)
TestLauncher: use SetExpoActive |
1028 |
WM->SetExpoActive(true); |
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
1029 |
}
|
1030 |
||
3566.4.19
by Marco Trevisan (Treviño)
TestLauncher: verify icon desaturation when it's added on overlay opened |
1031 |
TEST_F(TestLauncher, IconIsDesaturatedWhenAddedInOverlayMode) |
1032 |
{
|
|
1033 |
WM->SetScaleActive(true); |
|
1034 |
launcher_->SetHover(false); |
|
1035 |
ASSERT_TRUE(launcher_->IsOverlayOpen()); |
|
1036 |
||
1037 |
auto icon = AddMockIcons(1).front(); |
|
1038 |
||
1039 |
EXPECT_TRUE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1040 |
EXPECT_FLOAT_EQ(1.0f, icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1041 |
}
|
|
1042 |
||
1043 |
TEST_F(TestLauncher, IconIsNotDesaturatedWhenAddedInOverlayModeWithMouseOver) |
|
1044 |
{
|
|
1045 |
WM->SetScaleActive(true); |
|
1046 |
launcher_->SetHover(true); |
|
1047 |
ASSERT_TRUE(launcher_->IsOverlayOpen()); |
|
1048 |
||
1049 |
auto icon = AddMockIcons(1).front(); |
|
1050 |
||
1051 |
EXPECT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1052 |
EXPECT_FLOAT_EQ(0.0f, icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1053 |
}
|
|
1054 |
||
1055 |
TEST_F(TestLauncher, IconIsNotDesaturatedWhenAddedInNormalMode) |
|
1056 |
{
|
|
1057 |
launcher_->SetHover(false); |
|
1058 |
ASSERT_FALSE(launcher_->IsOverlayOpen()); |
|
1059 |
||
1060 |
auto icon = AddMockIcons(1).front(); |
|
1061 |
||
1062 |
EXPECT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1063 |
EXPECT_FLOAT_EQ(0.0f, icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor())); |
|
1064 |
}
|
|
1065 |
||
3566.1.11
by Marco Trevisan (Treviño)
TestLauncher: verify launcher behavior on Spread |
1066 |
} // namespace launcher |
1067 |
} // namespace unity |