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

Unified Diff: content/renderer/device_sensors/device_light_event_pump_unittest.cc

Issue 2037513002: Convert device_sensors to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@conversion--mime-registry
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/device_sensors/device_light_event_pump_unittest.cc
diff --git a/content/renderer/device_sensors/device_light_event_pump_unittest.cc b/content/renderer/device_sensors/device_light_event_pump_unittest.cc
index 5995ec698c46a003f5eee6b5a57e617db7798f36..96b855dff560ca7c0dc7423c27cc98aaac459d46 100644
--- a/content/renderer/device_sensors/device_light_event_pump_unittest.cc
+++ b/content/renderer/device_sensors/device_light_event_pump_unittest.cc
@@ -10,6 +10,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "content/common/device_sensors/device_light_hardware_buffer.h"
#include "content/public/test/test_utils.h"
+#include "mojo/public/cpp/system/buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
@@ -46,8 +47,8 @@ class DeviceLightEventPumpForTesting : public DeviceLightEventPump {
: DeviceLightEventPump(0) {}
~DeviceLightEventPumpForTesting() override {}
- void OnDidStart(base::SharedMemoryHandle renderer_handle) {
- DeviceLightEventPump::OnDidStart(renderer_handle);
+ void DidStart(mojo::ScopedSharedBufferHandle renderer_handle) {
+ DeviceLightEventPump::DidStart(std::move(renderer_handle));
}
void SendStartMessage() override {}
void SendStopMessage() override {}
@@ -75,8 +76,6 @@ class DeviceLightEventPumpTest : public testing::Test {
light_pump_.reset(new DeviceLightEventPumpForTesting);
buffer_ = static_cast<DeviceLightHardwareBuffer*>(shared_memory_.memory());
ASSERT_NE(null_buffer, buffer_);
- ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(),
- &handle_));
}
void InitBuffer() {
@@ -86,13 +85,16 @@ class DeviceLightEventPumpTest : public testing::Test {
MockDeviceLightListener* listener() { return listener_.get(); }
DeviceLightEventPumpForTesting* light_pump() { return light_pump_.get(); }
- base::SharedMemoryHandle handle() { return handle_; }
+ mojo::ScopedSharedBufferHandle handle() {
+ return mojo::WrapSharedMemoryHandle(
+ base::SharedMemory::DuplicateHandle(shared_memory_.handle()),
+ sizeof(DeviceLightHardwareBuffer), false);
+ }
DeviceLightHardwareBuffer* buffer() { return buffer_; }
private:
std::unique_ptr<MockDeviceLightListener> listener_;
std::unique_ptr<DeviceLightEventPumpForTesting> light_pump_;
- base::SharedMemoryHandle handle_;
base::SharedMemory shared_memory_;
DeviceLightHardwareBuffer* buffer_;
@@ -105,7 +107,7 @@ TEST_F(DeviceLightEventPumpTest, DidStartPolling) {
InitBuffer();
light_pump()->Start(listener());
- light_pump()->OnDidStart(handle());
+ light_pump()->DidStart(handle());
base::MessageLoop::current()->Run();
@@ -118,7 +120,7 @@ TEST_F(DeviceLightEventPumpTest, FireAllNullEvent) {
base::MessageLoopForUI loop;
light_pump()->Start(listener());
- light_pump()->OnDidStart(handle());
+ light_pump()->DidStart(handle());
base::MessageLoop::current()->Run();
@@ -133,7 +135,7 @@ TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) {
InitBuffer();
light_pump()->Start(listener());
- light_pump()->OnDidStart(handle());
+ light_pump()->DidStart(handle());
base::MessageLoop::current()->Run();

Powered by Google App Engine
This is Rietveld 408576698