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

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

Issue 633303002: Replace FINAL and OVERRIDE with their C++11 counterparts in content/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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"
11 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 11 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class MockDeviceLightListener : public blink::WebDeviceLightListener { 15 class MockDeviceLightListener : public blink::WebDeviceLightListener {
16 public: 16 public:
17 MockDeviceLightListener() : did_change_device_light_(false) {} 17 MockDeviceLightListener() : did_change_device_light_(false) {}
18 virtual ~MockDeviceLightListener() {} 18 virtual ~MockDeviceLightListener() {}
19 19
20 virtual void didChangeDeviceLight(double value) OVERRIDE { 20 virtual void didChangeDeviceLight(double value) override {
21 data_.value = value; 21 data_.value = value;
22 did_change_device_light_ = true; 22 did_change_device_light_ = true;
23 } 23 }
24 24
25 bool did_change_device_light() const { return did_change_device_light_; } 25 bool did_change_device_light() const { return did_change_device_light_; }
26 26
27 void set_did_change_device_light(bool value) { 27 void set_did_change_device_light(bool value) {
28 did_change_device_light_ = value; 28 did_change_device_light_ = value;
29 } 29 }
30 30
31 const DeviceLightData& data() const { return data_; } 31 const DeviceLightData& data() const { return data_; }
32 32
33 private: 33 private:
34 bool did_change_device_light_; 34 bool did_change_device_light_;
35 DeviceLightData data_; 35 DeviceLightData data_;
36 36
37 DISALLOW_COPY_AND_ASSIGN(MockDeviceLightListener); 37 DISALLOW_COPY_AND_ASSIGN(MockDeviceLightListener);
38 }; 38 };
39 39
40 class DeviceLightEventPumpForTesting : public DeviceLightEventPump { 40 class DeviceLightEventPumpForTesting : public DeviceLightEventPump {
41 public: 41 public:
42 DeviceLightEventPumpForTesting() 42 DeviceLightEventPumpForTesting()
43 : DeviceLightEventPump(0) {} 43 : DeviceLightEventPump(0) {}
44 virtual ~DeviceLightEventPumpForTesting() {} 44 virtual ~DeviceLightEventPumpForTesting() {}
45 45
46 void OnDidStart(base::SharedMemoryHandle renderer_handle) { 46 void OnDidStart(base::SharedMemoryHandle renderer_handle) {
47 DeviceLightEventPump::OnDidStart(renderer_handle); 47 DeviceLightEventPump::OnDidStart(renderer_handle);
48 } 48 }
49 virtual void SendStartMessage() OVERRIDE { } 49 virtual void SendStartMessage() override { }
50 virtual void SendStopMessage() OVERRIDE { } 50 virtual void SendStopMessage() override { }
51 virtual void FireEvent() OVERRIDE { 51 virtual void FireEvent() override {
52 DeviceLightEventPump::FireEvent(); 52 DeviceLightEventPump::FireEvent();
53 Stop(); 53 Stop();
54 base::MessageLoop::current()->QuitWhenIdle(); 54 base::MessageLoop::current()->QuitWhenIdle();
55 } 55 }
56 56
57 private: 57 private:
58 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPumpForTesting); 58 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPumpForTesting);
59 }; 59 };
60 60
61 class DeviceLightEventPumpTest : public testing::Test { 61 class DeviceLightEventPumpTest : public testing::Test {
62 public: 62 public:
63 DeviceLightEventPumpTest() { 63 DeviceLightEventPumpTest() {
64 EXPECT_TRUE(shared_memory_.CreateAndMapAnonymous( 64 EXPECT_TRUE(shared_memory_.CreateAndMapAnonymous(
65 sizeof(DeviceLightHardwareBuffer))); 65 sizeof(DeviceLightHardwareBuffer)));
66 } 66 }
67 67
68 protected: 68 protected:
69 virtual void SetUp() OVERRIDE { 69 virtual void SetUp() override {
70 const DeviceLightHardwareBuffer* null_buffer = NULL; 70 const DeviceLightHardwareBuffer* null_buffer = NULL;
71 listener_.reset(new MockDeviceLightListener); 71 listener_.reset(new MockDeviceLightListener);
72 light_pump_.reset(new DeviceLightEventPumpForTesting); 72 light_pump_.reset(new DeviceLightEventPumpForTesting);
73 buffer_ = static_cast<DeviceLightHardwareBuffer*>(shared_memory_.memory()); 73 buffer_ = static_cast<DeviceLightHardwareBuffer*>(shared_memory_.memory());
74 ASSERT_NE(null_buffer, buffer_); 74 ASSERT_NE(null_buffer, buffer_);
75 ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(), 75 ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(),
76 &handle_)); 76 &handle_));
77 } 77 }
78 78
79 void InitBuffer() { 79 void InitBuffer() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::Bind(&DeviceLightEventPumpForTesting::FireEvent, 151 base::Bind(&DeviceLightEventPumpForTesting::FireEvent,
152 base::Unretained(light_pump()))); 152 base::Unretained(light_pump())));
153 base::MessageLoop::current()->Run(); 153 base::MessageLoop::current()->Run();
154 154
155 // 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.
156 EXPECT_FALSE(listener()->did_change_device_light()); 156 EXPECT_FALSE(listener()->did_change_device_light());
157 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value)); 157 EXPECT_EQ(last_seen_data, static_cast<double>(received_data.value));
158 } 158 }
159 159
160 } // namespace content 160 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/device_sensors/device_light_event_pump.h ('k') | content/renderer/device_sensors/device_motion_event_pump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698