| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class DeviceOrientationEventPumpTest : public testing::Test { | 68 class DeviceOrientationEventPumpTest : public testing::Test { |
| 69 public: | 69 public: |
| 70 DeviceOrientationEventPumpTest() { | 70 DeviceOrientationEventPumpTest() { |
| 71 EXPECT_TRUE(shared_memory_.CreateAndMapAnonymous( | 71 EXPECT_TRUE(shared_memory_.CreateAndMapAnonymous( |
| 72 sizeof(DeviceOrientationHardwareBuffer))); | 72 sizeof(DeviceOrientationHardwareBuffer))); |
| 73 } | 73 } |
| 74 | 74 |
| 75 protected: | 75 protected: |
| 76 virtual void SetUp() override { | 76 void SetUp() override { |
| 77 const DeviceOrientationHardwareBuffer* null_buffer = NULL; | 77 const DeviceOrientationHardwareBuffer* null_buffer = NULL; |
| 78 listener_.reset(new MockDeviceOrientationListener); | 78 listener_.reset(new MockDeviceOrientationListener); |
| 79 orientation_pump_.reset(new DeviceOrientationEventPumpForTesting); | 79 orientation_pump_.reset(new DeviceOrientationEventPumpForTesting); |
| 80 buffer_ = static_cast<DeviceOrientationHardwareBuffer*>( | 80 buffer_ = static_cast<DeviceOrientationHardwareBuffer*>( |
| 81 shared_memory_.memory()); | 81 shared_memory_.memory()); |
| 82 ASSERT_NE(null_buffer, buffer_); | 82 ASSERT_NE(null_buffer, buffer_); |
| 83 memset(buffer_, 0, sizeof(DeviceOrientationHardwareBuffer)); | 83 memset(buffer_, 0, sizeof(DeviceOrientationHardwareBuffer)); |
| 84 ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(), | 84 ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(), |
| 85 &handle_)); | 85 &handle_)); |
| 86 } | 86 } |
| (...skipping 119 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 |