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

Side by Side Diff: ui/views/event_monitor_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/views/event_monitor_mac.mm ('k') | ui/views/examples/examples_main.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "ui/events/test/event_generator.h" 6 #include "ui/events/test/event_generator.h"
7 #include "ui/events/test/test_event_handler.h" 7 #include "ui/events/test/test_event_handler.h"
8 #include "ui/views/event_monitor.h" 8 #include "ui/views/event_monitor.h"
9 #include "ui/views/test/widget_test.h" 9 #include "ui/views/test/widget_test.h"
10 10
(...skipping 14 matching lines...) Expand all
25 new ui::test::EventGenerator(GetContext(), widget_->GetNativeWindow())); 25 new ui::test::EventGenerator(GetContext(), widget_->GetNativeWindow()));
26 generator_->set_targeting_application(true); 26 generator_->set_targeting_application(true);
27 } 27 }
28 void TearDown() override { 28 void TearDown() override {
29 widget_->CloseNow(); 29 widget_->CloseNow();
30 WidgetTest::TearDown(); 30 WidgetTest::TearDown();
31 } 31 }
32 32
33 protected: 33 protected:
34 Widget* widget_; 34 Widget* widget_;
35 scoped_ptr<ui::test::EventGenerator> generator_; 35 std::unique_ptr<ui::test::EventGenerator> generator_;
36 ui::test::TestEventHandler handler_; 36 ui::test::TestEventHandler handler_;
37 37
38 private: 38 private:
39 DISALLOW_COPY_AND_ASSIGN(EventMonitorTest); 39 DISALLOW_COPY_AND_ASSIGN(EventMonitorTest);
40 }; 40 };
41 41
42 TEST_F(EventMonitorTest, ShouldReceiveAppEventsWhileInstalled) { 42 TEST_F(EventMonitorTest, ShouldReceiveAppEventsWhileInstalled) {
43 scoped_ptr<EventMonitor> monitor( 43 std::unique_ptr<EventMonitor> monitor(
44 EventMonitor::CreateApplicationMonitor(&handler_)); 44 EventMonitor::CreateApplicationMonitor(&handler_));
45 45
46 generator_->ClickLeftButton(); 46 generator_->ClickLeftButton();
47 EXPECT_EQ(2, handler_.num_mouse_events()); 47 EXPECT_EQ(2, handler_.num_mouse_events());
48 48
49 monitor.reset(); 49 monitor.reset();
50 generator_->ClickLeftButton(); 50 generator_->ClickLeftButton();
51 EXPECT_EQ(2, handler_.num_mouse_events()); 51 EXPECT_EQ(2, handler_.num_mouse_events());
52 } 52 }
53 53
54 TEST_F(EventMonitorTest, ShouldReceiveWindowEventsWhileInstalled) { 54 TEST_F(EventMonitorTest, ShouldReceiveWindowEventsWhileInstalled) {
55 scoped_ptr<EventMonitor> monitor( 55 std::unique_ptr<EventMonitor> monitor(
56 EventMonitor::CreateWindowMonitor(&handler_, widget_->GetNativeWindow())); 56 EventMonitor::CreateWindowMonitor(&handler_, widget_->GetNativeWindow()));
57 57
58 generator_->ClickLeftButton(); 58 generator_->ClickLeftButton();
59 EXPECT_EQ(2, handler_.num_mouse_events()); 59 EXPECT_EQ(2, handler_.num_mouse_events());
60 60
61 monitor.reset(); 61 monitor.reset();
62 generator_->ClickLeftButton(); 62 generator_->ClickLeftButton();
63 EXPECT_EQ(2, handler_.num_mouse_events()); 63 EXPECT_EQ(2, handler_.num_mouse_events());
64 } 64 }
65 65
66 TEST_F(EventMonitorTest, ShouldNotReceiveEventsFromOtherWindow) { 66 TEST_F(EventMonitorTest, ShouldNotReceiveEventsFromOtherWindow) {
67 Widget* widget2 = CreateTopLevelNativeWidget(); 67 Widget* widget2 = CreateTopLevelNativeWidget();
68 scoped_ptr<EventMonitor> monitor( 68 std::unique_ptr<EventMonitor> monitor(
69 EventMonitor::CreateWindowMonitor(&handler_, widget2->GetNativeWindow())); 69 EventMonitor::CreateWindowMonitor(&handler_, widget2->GetNativeWindow()));
70 70
71 generator_->ClickLeftButton(); 71 generator_->ClickLeftButton();
72 EXPECT_EQ(0, handler_.num_mouse_events()); 72 EXPECT_EQ(0, handler_.num_mouse_events());
73 73
74 monitor.reset(); 74 monitor.reset();
75 widget2->CloseNow(); 75 widget2->CloseNow();
76 } 76 }
77 77
78 } // namespace test 78 } // namespace test
79 } // namespace views 79 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/event_monitor_mac.mm ('k') | ui/views/examples/examples_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698