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

Side by Side Diff: content/renderer/device_sensors/device_light_event_pump_unittest.cc

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR 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
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 "device_light_event_pump.h" 5 #include "device_light_event_pump.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
11 #include "content/common/device_sensors/device_light_hardware_buffer.h" 12 #include "content/common/device_sensors/device_light_hardware_buffer.h"
12 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 15 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class MockDeviceLightListener : public blink::WebDeviceLightListener { 19 class MockDeviceLightListener : public blink::WebDeviceLightListener {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 }; 101 };
101 102
102 TEST_F(DeviceLightEventPumpTest, DidStartPolling) { 103 TEST_F(DeviceLightEventPumpTest, DidStartPolling) {
103 base::MessageLoopForUI loop; 104 base::MessageLoopForUI loop;
104 105
105 InitBuffer(); 106 InitBuffer();
106 107
107 light_pump()->Start(listener()); 108 light_pump()->Start(listener());
108 light_pump()->OnDidStart(handle()); 109 light_pump()->OnDidStart(handle());
109 110
110 base::MessageLoop::current()->Run(); 111 base::RunLoop().Run();
111 112
112 const DeviceLightData& received_data = listener()->data(); 113 const DeviceLightData& received_data = listener()->data();
113 EXPECT_TRUE(listener()->did_change_device_light()); 114 EXPECT_TRUE(listener()->did_change_device_light());
114 EXPECT_EQ(1, static_cast<double>(received_data.value)); 115 EXPECT_EQ(1, static_cast<double>(received_data.value));
115 } 116 }
116 117
117 TEST_F(DeviceLightEventPumpTest, FireAllNullEvent) { 118 TEST_F(DeviceLightEventPumpTest, FireAllNullEvent) {
118 base::MessageLoopForUI loop; 119 base::MessageLoopForUI loop;
119 120
120 light_pump()->Start(listener()); 121 light_pump()->Start(listener());
121 light_pump()->OnDidStart(handle()); 122 light_pump()->OnDidStart(handle());
122 123
123 base::MessageLoop::current()->Run(); 124 base::RunLoop().Run();
124 125
125 const DeviceLightData& received_data = listener()->data(); 126 const DeviceLightData& received_data = listener()->data();
126 EXPECT_TRUE(listener()->did_change_device_light()); 127 EXPECT_TRUE(listener()->did_change_device_light());
127 EXPECT_FALSE(received_data.value); 128 EXPECT_FALSE(received_data.value);
128 } 129 }
129 130
130 TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) { 131 TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) {
131 base::MessageLoopForUI loop; 132 base::MessageLoopForUI loop;
132 133
133 InitBuffer(); 134 InitBuffer();
134 135
135 light_pump()->Start(listener()); 136 light_pump()->Start(listener());
136 light_pump()->OnDidStart(handle()); 137 light_pump()->OnDidStart(handle());
137 138
138 base::MessageLoop::current()->Run(); 139 base::RunLoop().Run();
139 140
140 const DeviceLightData& received_data = listener()->data(); 141 const DeviceLightData& received_data = listener()->data();
141 EXPECT_TRUE(listener()->did_change_device_light()); 142 EXPECT_TRUE(listener()->did_change_device_light());
142 EXPECT_EQ(1, static_cast<double>(received_data.value)); 143 EXPECT_EQ(1, static_cast<double>(received_data.value));
143 144
144 double last_seen_data = received_data.value; 145 double last_seen_data = received_data.value;
145 // Set next value to be same as previous value. 146 // Set next value to be same as previous value.
146 buffer()->data.value = 1.0; 147 buffer()->data.value = 1.0;
147 listener()->set_did_change_device_light(false); 148 listener()->set_did_change_device_light(false);
148 149
149 // Reset the pump's listener. 150 // Reset the pump's listener.
150 light_pump()->Start(listener()); 151 light_pump()->Start(listener());
151 152
152 base::ThreadTaskRunnerHandle::Get()->PostTask( 153 base::ThreadTaskRunnerHandle::Get()->PostTask(
153 FROM_HERE, base::Bind(&DeviceLightEventPumpForTesting::FireEvent, 154 FROM_HERE, base::Bind(&DeviceLightEventPumpForTesting::FireEvent,
154 base::Unretained(light_pump()))); 155 base::Unretained(light_pump())));
155 base::MessageLoop::current()->Run(); 156 base::RunLoop().Run();
156 157
157 // No change in device light as present value is same as previous value. 158 // No change in device light as present value is same as previous value.
158 EXPECT_FALSE(listener()->did_change_device_light()); 159 EXPECT_FALSE(listener()->did_change_device_light());
159 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value)); 160 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value));
160 } 161 }
161 162
162 } // namespace content 163 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_utils.cc ('k') | content/renderer/device_sensors/device_motion_event_pump_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698