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

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

Issue 2828913003: Replace "nested message loop" with "nested run loop" in comments. (Closed)
Patch Set: rebase Created 3 years, 7 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 | « ui/aura/window_event_dispatcher.cc ('k') | ui/base/clipboard/clipboard_aurax11.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 "GESTURE_SCROLL_END GESTURE_END", 2202 "GESTURE_SCROLL_END GESTURE_END",
2203 EventTypesToString(events)); 2203 EventTypesToString(events));
2204 ASSERT_EQ(2u, recorder.touch_locations().size()); 2204 ASSERT_EQ(2u, recorder.touch_locations().size());
2205 EXPECT_EQ(gfx::Point(-40, 10).ToString(), 2205 EXPECT_EQ(gfx::Point(-40, 10).ToString(),
2206 recorder.touch_locations()[0].ToString()); 2206 recorder.touch_locations()[0].ToString());
2207 EXPECT_EQ(gfx::Point(-40, 10).ToString(), 2207 EXPECT_EQ(gfx::Point(-40, 10).ToString(),
2208 recorder.touch_locations()[1].ToString()); 2208 recorder.touch_locations()[1].ToString());
2209 root_window()->RemovePreTargetHandler(&recorder); 2209 root_window()->RemovePreTargetHandler(&recorder);
2210 } 2210 }
2211 2211
2212 // This handler triggers a nested message loop when it receives a right click 2212 // This handler triggers a nested run loop when it receives a right click
2213 // event, and runs a single callback in the nested message loop. 2213 // event, and runs a single callback in the nested run loop.
2214 class TriggerNestedLoopOnRightMousePress : public ui::test::TestEventHandler { 2214 class TriggerNestedLoopOnRightMousePress : public ui::test::TestEventHandler {
2215 public: 2215 public:
2216 explicit TriggerNestedLoopOnRightMousePress(const base::Closure& callback) 2216 explicit TriggerNestedLoopOnRightMousePress(const base::Closure& callback)
2217 : callback_(callback) {} 2217 : callback_(callback) {}
2218 ~TriggerNestedLoopOnRightMousePress() override {} 2218 ~TriggerNestedLoopOnRightMousePress() override {}
2219 2219
2220 const gfx::Point mouse_move_location() const { return mouse_move_location_; } 2220 const gfx::Point mouse_move_location() const { return mouse_move_location_; }
2221 2221
2222 private: 2222 private:
2223 void OnMouseEvent(ui::MouseEvent* mouse) override { 2223 void OnMouseEvent(ui::MouseEvent* mouse) override {
(...skipping 13 matching lines...) Expand all
2237 mouse_move_location_ = mouse->location(); 2237 mouse_move_location_ = mouse->location();
2238 } 2238 }
2239 } 2239 }
2240 2240
2241 base::Closure callback_; 2241 base::Closure callback_;
2242 gfx::Point mouse_move_location_; 2242 gfx::Point mouse_move_location_;
2243 2243
2244 DISALLOW_COPY_AND_ASSIGN(TriggerNestedLoopOnRightMousePress); 2244 DISALLOW_COPY_AND_ASSIGN(TriggerNestedLoopOnRightMousePress);
2245 }; 2245 };
2246 2246
2247 // Tests that if dispatching a 'held' event triggers a nested message loop, then 2247 // Tests that if dispatching a 'held' event triggers a nested run loop, then
2248 // the events that are dispatched from the nested message loop are transformed 2248 // the events that are dispatched from the nested run loop are transformed
2249 // correctly. 2249 // correctly.
2250 TEST_P(WindowEventDispatcherTestInHighDPI, 2250 TEST_P(WindowEventDispatcherTestInHighDPI,
2251 EventsTransformedInRepostedEventTriggeredNestedLoop) { 2251 EventsTransformedInRepostedEventTriggeredNestedLoop) {
2252 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); 2252 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL));
2253 // Make sure the window is visible. 2253 // Make sure the window is visible.
2254 RunAllPendingInMessageLoop(); 2254 RunAllPendingInMessageLoop();
2255 2255
2256 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), 2256 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80),
2257 gfx::Point(80, 80), ui::EventTimeForNow(), 2257 gfx::Point(80, 80), ui::EventTimeForNow(),
2258 ui::EF_NONE, ui::EF_NONE); 2258 ui::EF_NONE, ui::EF_NONE);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 base::RunLoop run_loop; 2904 base::RunLoop run_loop;
2905 base::MessageLoop::current()->task_runner()->PostTask( 2905 base::MessageLoop::current()->task_runner()->PostTask(
2906 FROM_HERE, base::Bind(&NestedLocationDelegate::InRunMessageLoop, 2906 FROM_HERE, base::Bind(&NestedLocationDelegate::InRunMessageLoop,
2907 base::Unretained(this), &run_loop)); 2907 base::Unretained(this), &run_loop));
2908 run_loop.Run(); 2908 run_loop.Run();
2909 initial_run_loop->Quit(); 2909 initial_run_loop->Quit();
2910 } 2910 }
2911 2911
2912 void InRunMessageLoop(base::RunLoop* run_loop) { 2912 void InRunMessageLoop(base::RunLoop* run_loop) {
2913 ++nested_message_loop_count_; 2913 ++nested_message_loop_count_;
2914 // Nested message loops trigger falling back to using the location from 2914 // nested run loops trigger falling back to using the location from
2915 // WindowTreeClient, which is 0,0. 2915 // WindowTreeClient, which is 0,0.
2916 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); 2916 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location());
2917 run_loop->Quit(); 2917 run_loop->Quit();
2918 } 2918 }
2919 2919
2920 int mouse_event_count_ = 0; 2920 int mouse_event_count_ = 0;
2921 // Incremented when the deepest message loop is encountered. 2921 // Incremented when the deepest message loop is encountered.
2922 int nested_message_loop_count_ = 0; 2922 int nested_message_loop_count_ = 0;
2923 gfx::Point last_mouse_location_; 2923 gfx::Point last_mouse_location_;
2924 2924
(...skipping 22 matching lines...) Expand all
2947 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); 2947 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count());
2948 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); 2948 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count());
2949 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); 2949 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location());
2950 2950
2951 // After dispatch the location should fallback to that of the 2951 // After dispatch the location should fallback to that of the
2952 // WindowTreeClient, which defaults to 0,0. 2952 // WindowTreeClient, which defaults to 0,0.
2953 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); 2953 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location());
2954 } 2954 }
2955 2955
2956 } // namespace aura 2956 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698