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

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

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "content/common/device_sensors/device_light_hardware_buffer.h" 8 #include "content/common/device_sensors/device_light_hardware_buffer.h"
9 #include "content/public/test/test_utils.h" 9 #include "content/public/test/test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 light_pump()->Start(listener()); 104 light_pump()->Start(listener());
105 light_pump()->OnDidStart(handle()); 105 light_pump()->OnDidStart(handle());
106 106
107 base::MessageLoop::current()->Run(); 107 base::MessageLoop::current()->Run();
108 108
109 const DeviceLightData& received_data = listener()->data(); 109 const DeviceLightData& received_data = listener()->data();
110 EXPECT_TRUE(listener()->did_change_device_light()); 110 EXPECT_TRUE(listener()->did_change_device_light());
111 EXPECT_EQ(1, static_cast<double>(received_data.value)); 111 EXPECT_EQ(1, static_cast<double>(received_data.value));
112 } 112 }
113 113
114 TEST_F(DeviceLightEventPumpTest, FireAllNullEvent) {
115 base::MessageLoopForUI loop;
116
117 light_pump()->Start(listener());
118 light_pump()->OnDidStart(handle());
119
120 base::MessageLoop::current()->Run();
121
122 const DeviceLightData& received_data = listener()->data();
123 EXPECT_TRUE(listener()->did_change_device_light());
124 EXPECT_FALSE(received_data.value);
125 }
126
114 TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) { 127 TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) {
115 base::MessageLoopForUI loop; 128 base::MessageLoopForUI loop;
116 129
117 InitBuffer(); 130 InitBuffer();
118 131
119 light_pump()->Start(listener()); 132 light_pump()->Start(listener());
120 light_pump()->OnDidStart(handle()); 133 light_pump()->OnDidStart(handle());
121 134
122 base::MessageLoop::current()->Run(); 135 base::MessageLoop::current()->Run();
123 136
(...skipping 14 matching lines...) Expand all
138 base::Bind(&DeviceLightEventPumpForTesting::FireEvent, 151 base::Bind(&DeviceLightEventPumpForTesting::FireEvent,
139 base::Unretained(light_pump()))); 152 base::Unretained(light_pump())));
140 base::MessageLoop::current()->Run(); 153 base::MessageLoop::current()->Run();
141 154
142 // No change in device light as present value is same as previous value. 155 // No change in device light as present value is same as previous value.
143 EXPECT_FALSE(listener()->did_change_device_light()); 156 EXPECT_FALSE(listener()->did_change_device_light());
144 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value)); 157 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value));
145 } 158 }
146 159
147 } // namespace content 160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698