Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: components/exo/touch_unittest.cc

Issue 2127263002: Keep the SystemModalContainerEventHandler added (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep the SystemModalContainerEventHandler added Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/pointer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/shell_window_ids.h"
5 #include "ash/common/wm/window_positioner.h" 6 #include "ash/common/wm/window_positioner.h"
7 #include "ash/common/wm_shell.h"
6 #include "ash/shell.h" 8 #include "ash/shell.h"
7 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
8 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
9 #include "components/exo/shell_surface.h" 11 #include "components/exo/shell_surface.h"
10 #include "components/exo/surface.h" 12 #include "components/exo/surface.h"
11 #include "components/exo/test/exo_test_base.h" 13 #include "components/exo/test/exo_test_base.h"
12 #include "components/exo/test/exo_test_helper.h" 14 #include "components/exo/test/exo_test_helper.h"
13 #include "components/exo/touch.h" 15 #include "components/exo/touch.h"
14 #include "components/exo/touch_delegate.h" 16 #include "components/exo/touch_delegate.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // One touch point being canceled is enough for OnTouchCancel to be called. 183 // One touch point being canceled is enough for OnTouchCancel to be called.
182 EXPECT_CALL(delegate, OnTouchCancel()); 184 EXPECT_CALL(delegate, OnTouchCancel());
183 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, 185 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1,
184 ui::EventTimeForNow()); 186 ui::EventTimeForNow());
185 generator.Dispatch(&cancel_event); 187 generator.Dispatch(&cancel_event);
186 188
187 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); 189 EXPECT_CALL(delegate, OnTouchDestroying(touch.get()));
188 touch.reset(); 190 touch.reset();
189 } 191 }
190 192
193 TEST_F(TouchTest, IgnoreTouchEventDuringModal) {
194 std::unique_ptr<Surface> surface(new Surface);
195 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
196 std::unique_ptr<Buffer> buffer(
197 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10))));
198 surface->Attach(buffer.get());
199 surface->Commit();
200 gfx::Point location = surface->window()->GetBoundsInScreen().origin();
201
202 MockTouchDelegate delegate;
203 std::unique_ptr<Touch> touch(new Touch(&delegate));
204 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
205
206 // Create surface for modal window.
207 std::unique_ptr<Surface> surface2(new Surface);
208 std::unique_ptr<ShellSurface> shell_surface2(
209 new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 5, 5), true,
210 ash::kShellWindowId_SystemModalContainer));
211 std::unique_ptr<Buffer> buffer2(
212 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5))));
213 surface2->Attach(buffer2.get());
214 surface2->Commit();
215 ash::wm::CenterWindow(surface2->window());
216 gfx::Point location2 = surface2->window()->GetBoundsInScreen().origin();
217
218 // Make the window modal.
219 shell_surface2->SetSystemModal(true);
220 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
221
222 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(surface.get()))
223 .WillRepeatedly(testing::Return(true));
224 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(surface2.get()))
225 .WillRepeatedly(testing::Return(true));
226
227 // Check if touch events on modal window are registered.
228 {
229 testing::InSequence sequence;
230 EXPECT_CALL(delegate, OnTouchDown(surface2.get(), testing::_, testing::_,
231 gfx::Point()));
232 EXPECT_CALL(delegate,
233 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1)));
234 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_));
235 }
236 generator.set_current_location(location2);
237 generator.PressMoveAndReleaseTouchBy(1, 1);
238
239 // Check if touch events on non-modal window are ignored.
240 {
241 testing::InSequence sequence;
242 EXPECT_CALL(delegate, OnTouchDown(surface.get(), testing::_, testing::_,
243 gfx::Point()))
244 .Times(0);
245 EXPECT_CALL(delegate,
246 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1)))
247 .Times(0);
248 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0);
249 }
250 generator.set_current_location(location);
251 generator.PressMoveAndReleaseTouchBy(1, 1);
252
253 // Make the window non-modal.
254 shell_surface2->SetSystemModal(false);
255 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
256
257 // Check if touch events on non-modal window are registered.
258 {
259 testing::InSequence sequence;
260 EXPECT_CALL(delegate, OnTouchDown(surface.get(), testing::_, testing::_,
261 gfx::Point()));
262 EXPECT_CALL(delegate,
263 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1)));
264 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_));
265 }
266 generator.set_current_location(location);
267 generator.PressMoveAndReleaseTouchBy(1, 1);
268
269 EXPECT_CALL(delegate, OnTouchDestroying(touch.get()));
270 touch.reset();
271 }
272
191 } // namespace 273 } // namespace
192 } // namespace exo 274 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/pointer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698