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

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

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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/test/ui_controls_factory_aurawin.cc ('k') | ui/base/x/selection_requestor_unittest.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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/aura/client/capture_client.h" 19 #include "ui/aura/client/capture_client.h"
19 #include "ui/aura/client/event_client.h" 20 #include "ui/aura/client/event_client.h"
20 #include "ui/aura/client/focus_client.h" 21 #include "ui/aura/client/focus_client.h"
21 #include "ui/aura/env.h" 22 #include "ui/aura/env.h"
22 #include "ui/aura/test/aura_test_base.h" 23 #include "ui/aura/test/aura_test_base.h"
23 #include "ui/aura/test/env_test_helper.h" 24 #include "ui/aura/test/env_test_helper.h"
24 #include "ui/aura/test/test_cursor_client.h" 25 #include "ui/aura/test/test_cursor_client.h"
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 // Reset any event the window may have received when bringing up the window 2010 // Reset any event the window may have received when bringing up the window
2010 // (e.g. mouse-move events if the mouse cursor is over the window). 2011 // (e.g. mouse-move events if the mouse cursor is over the window).
2011 handler_.Reset(); 2012 handler_.Reset();
2012 2013
2013 // Start a nested message-loop, post an event to be dispatched, and then 2014 // Start a nested message-loop, post an event to be dispatched, and then
2014 // terminate the message-loop. When the message-loop unwinds and gets back, 2015 // terminate the message-loop. When the message-loop unwinds and gets back,
2015 // the reposted event should not have fired. 2016 // the reposted event should not have fired.
2016 std::unique_ptr<ui::MouseEvent> mouse(new ui::MouseEvent( 2017 std::unique_ptr<ui::MouseEvent> mouse(new ui::MouseEvent(
2017 ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10), 2018 ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
2018 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); 2019 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
2019 message_loop()->PostTask( 2020 message_loop()->task_runner()->PostTask(
2020 FROM_HERE, 2021 FROM_HERE,
2021 base::Bind(&WindowEventDispatcherTestWithMessageLoop::RepostEventHelper, 2022 base::Bind(&WindowEventDispatcherTestWithMessageLoop::RepostEventHelper,
2022 host()->dispatcher(), 2023 host()->dispatcher(), base::Passed(&mouse)));
2023 base::Passed(&mouse))); 2024 message_loop()->task_runner()->PostTask(
2024 message_loop()->PostTask(FROM_HERE, message_loop()->QuitWhenIdleClosure()); 2025 FROM_HERE, message_loop()->QuitWhenIdleClosure());
2025 2026
2026 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop()); 2027 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop());
2027 base::RunLoop loop; 2028 base::RunLoop loop;
2028 loop.Run(); 2029 loop.Run();
2029 EXPECT_EQ(0, handler_.num_mouse_events()); 2030 EXPECT_EQ(0, handler_.num_mouse_events());
2030 2031
2031 // Let the current message-loop run. The event-handler will terminate the 2032 // Let the current message-loop run. The event-handler will terminate the
2032 // message-loop when it receives the reposted event. 2033 // message-loop when it receives the reposted event.
2033 } 2034 }
2034 2035
(...skipping 23 matching lines...) Expand all
2058 std::unique_ptr<Window> window_; 2059 std::unique_ptr<Window> window_;
2059 ExitMessageLoopOnMousePress handler_; 2060 ExitMessageLoopOnMousePress handler_;
2060 2061
2061 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop); 2062 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop);
2062 }; 2063 };
2063 2064
2064 TEST_F(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) { 2065 TEST_F(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) {
2065 CHECK(!message_loop()->is_running()); 2066 CHECK(!message_loop()->is_running());
2066 // Perform the test in a callback, so that it runs after the message-loop 2067 // Perform the test in a callback, so that it runs after the message-loop
2067 // starts. 2068 // starts.
2068 message_loop()->PostTask( 2069 message_loop()->task_runner()->PostTask(
2069 FROM_HERE, base::Bind( 2070 FROM_HERE, base::Bind(&WindowEventDispatcherTestWithMessageLoop::RunTest,
2070 &WindowEventDispatcherTestWithMessageLoop::RunTest, 2071 base::Unretained(this)));
2071 base::Unretained(this))); 2072 base::RunLoop().Run();
2072 message_loop()->Run();
2073 } 2073 }
2074 2074
2075 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { 2075 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest {
2076 public: 2076 public:
2077 WindowEventDispatcherTestInHighDPI() {} 2077 WindowEventDispatcherTestInHighDPI() {}
2078 ~WindowEventDispatcherTestInHighDPI() override {} 2078 ~WindowEventDispatcherTestInHighDPI() override {}
2079 2079
2080 void DispatchEvent(ui::Event* event) { 2080 void DispatchEvent(ui::Event* event) {
2081 DispatchEventUsingWindowDispatcher(event); 2081 DispatchEventUsingWindowDispatcher(event);
2082 } 2082 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|. 2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|.
2664 test_screen()->SetDeviceScaleFactor(2.f); 2664 test_screen()->SetDeviceScaleFactor(2.f);
2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11)); 2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11));
2666 RunAllPendingInMessageLoop(); 2666 RunAllPendingInMessageLoop();
2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED)); 2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED));
2668 2668
2669 w->RemovePreTargetHandler(&recorder); 2669 w->RemovePreTargetHandler(&recorder);
2670 } 2670 }
2671 2671
2672 } // namespace aura 2672 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/ui_controls_factory_aurawin.cc ('k') | ui/base/x/selection_requestor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698