| OLD | NEW |
| 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_orientation_event_pump.h" | 5 #include "device_orientation_event_pump.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" | 9 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" |
| 10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 bool did_change_device_orientation_; | 41 bool did_change_device_orientation_; |
| 42 blink::WebDeviceOrientationData data_; | 42 blink::WebDeviceOrientationData data_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(MockDeviceOrientationListener); | 44 DISALLOW_COPY_AND_ASSIGN(MockDeviceOrientationListener); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class DeviceOrientationEventPumpForTesting : public DeviceOrientationEventPump { | 47 class DeviceOrientationEventPumpForTesting : public DeviceOrientationEventPump { |
| 48 public: | 48 public: |
| 49 DeviceOrientationEventPumpForTesting() | 49 DeviceOrientationEventPumpForTesting() |
| 50 : DeviceOrientationEventPump(0) { } | 50 : DeviceOrientationEventPump(0) { } |
| 51 virtual ~DeviceOrientationEventPumpForTesting() { } | 51 ~DeviceOrientationEventPumpForTesting() override {} |
| 52 | 52 |
| 53 void OnDidStart(base::SharedMemoryHandle renderer_handle) { | 53 void OnDidStart(base::SharedMemoryHandle renderer_handle) { |
| 54 DeviceOrientationEventPump::OnDidStart(renderer_handle); | 54 DeviceOrientationEventPump::OnDidStart(renderer_handle); |
| 55 } | 55 } |
| 56 virtual void SendStartMessage() override { } | 56 void SendStartMessage() override {} |
| 57 virtual void SendStopMessage() override { } | 57 void SendStopMessage() override {} |
| 58 virtual void FireEvent() override { | 58 void FireEvent() override { |
| 59 DeviceOrientationEventPump::FireEvent(); | 59 DeviceOrientationEventPump::FireEvent(); |
| 60 Stop(); | 60 Stop(); |
| 61 base::MessageLoop::current()->QuitWhenIdle(); | 61 base::MessageLoop::current()->QuitWhenIdle(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPumpForTesting); | 65 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPumpForTesting); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class DeviceOrientationEventPumpTest : public testing::Test { | 68 class DeviceOrientationEventPumpTest : public testing::Test { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, | 206 base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, |
| 207 base::Unretained(orientation_pump()))); | 207 base::Unretained(orientation_pump()))); |
| 208 base::MessageLoop::current()->Run(); | 208 base::MessageLoop::current()->Run(); |
| 209 | 209 |
| 210 EXPECT_TRUE(listener()->did_change_device_orientation()); | 210 EXPECT_TRUE(listener()->did_change_device_orientation()); |
| 211 EXPECT_EQ(1 + DeviceOrientationEventPump::kOrientationThreshold, | 211 EXPECT_EQ(1 + DeviceOrientationEventPump::kOrientationThreshold, |
| 212 static_cast<double>(received_data.alpha)); | 212 static_cast<double>(received_data.alpha)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace content | 215 } // namespace content |
| OLD | NEW |