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

Side by Side Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 380343002: aura: Make sure redirected events have the correct location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-clang-build Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/extended_desktop_unittest.cc ('k') | ui/aura/window_targeter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/client/capture_client.h"
12 #include "ui/aura/client/event_client.h" 13 #include "ui/aura/client/event_client.h"
13 #include "ui/aura/client/focus_client.h" 14 #include "ui/aura/client/focus_client.h"
14 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
15 #include "ui/aura/test/aura_test_base.h" 16 #include "ui/aura/test/aura_test_base.h"
16 #include "ui/aura/test/env_test_helper.h" 17 #include "ui/aura/test/env_test_helper.h"
17 #include "ui/aura/test/event_generator.h" 18 #include "ui/aura/test/event_generator.h"
18 #include "ui/aura/test/test_cursor_client.h" 19 #include "ui/aura/test/test_cursor_client.h"
19 #include "ui/aura/test/test_screen.h" 20 #include "ui/aura/test/test_screen.h"
20 #include "ui/aura/test/test_window_delegate.h" 21 #include "ui/aura/test/test_window_delegate.h"
21 #include "ui/aura/test/test_windows.h" 22 #include "ui/aura/test/test_windows.h"
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 // Reset the mouse-event counts for |window|. 2197 // Reset the mouse-event counts for |window|.
2197 delegate.GetMouseMotionCountsAndReset(); 2198 delegate.GetMouseMotionCountsAndReset();
2198 2199
2199 // Notify both hosts that the cursor is now hidden. This should send a single 2200 // Notify both hosts that the cursor is now hidden. This should send a single
2200 // mouse-exit event to |window|. 2201 // mouse-exit event to |window|.
2201 host()->OnCursorVisibilityChanged(false); 2202 host()->OnCursorVisibilityChanged(false);
2202 second_host->OnCursorVisibilityChanged(false); 2203 second_host->OnCursorVisibilityChanged(false);
2203 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); 2204 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset());
2204 } 2205 }
2205 2206
2207 TEST_F(WindowEventDispatcherTest,
2208 RedirectedEventToDifferentDispatcherLocation) {
2209 scoped_ptr<WindowTreeHost> second_host(
2210 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
2211 second_host->InitHost();
2212 client::SetCaptureClient(second_host->window(),
2213 client::GetCaptureClient(root_window()));
2214
2215 test::EventCountDelegate delegate;
2216 scoped_ptr<Window> window_first(CreateTestWindowWithDelegate(&delegate, 123,
2217 gfx::Rect(20, 10, 10, 20), root_window()));
2218 window_first->Show();
2219
2220 scoped_ptr<Window> window_second(CreateTestWindowWithDelegate(&delegate, 12,
2221 gfx::Rect(10, 10, 20, 30), second_host->window()));
2222 window_second->Show();
2223
2224 window_second->SetCapture();
2225 EXPECT_EQ(window_second.get(),
2226 client::GetCaptureWindow(root_window()));
2227
2228 // Send an event to the first host. Make sure it goes to |window_second| in
2229 // |second_host| instead (since it has capture).
2230 EventFilterRecorder recorder_first;
2231 window_first->AddPreTargetHandler(&recorder_first);
2232 EventFilterRecorder recorder_second;
2233 window_second->AddPreTargetHandler(&recorder_second);
2234 const gfx::Point event_location(25, 15);
2235 ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, event_location,
2236 event_location, ui::EF_LEFT_MOUSE_BUTTON,
2237 ui::EF_LEFT_MOUSE_BUTTON);
2238 DispatchEventUsingWindowDispatcher(&mouse);
2239 EXPECT_TRUE(recorder_first.events().empty());
2240 ASSERT_EQ(1u, recorder_second.events().size());
2241 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder_second.events()[0]);
2242 EXPECT_EQ(event_location.ToString(),
2243 recorder_second.mouse_locations()[0].ToString());
2244 }
2245
2206 } // namespace aura 2246 } // namespace aura
OLDNEW
« no previous file with comments | « ash/extended_desktop_unittest.cc ('k') | ui/aura/window_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698