Index: content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc |
diff --git a/content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc b/content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc |
index b652413d4cbc76c0fa78d2f12312a692cf3e305d..aed580b22a3e65c38005a09cc622758c82e429b8 100644 |
--- a/content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc |
+++ b/content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc |
@@ -2,15 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
+ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
-#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
#include "content/browser/screen_orientation/screen_orientation_provider.h" |
#include "content/common/screen_orientation_messages.h" |
-#include "content/public/browser/browser_context.h" |
-#include "content/public/test/mock_render_process_host.h" |
-#include "content/public/test/test_browser_context.h" |
-#include "content/public/test/test_browser_thread_bundle.h" |
#include "content/public/test/test_utils.h" |
#include "ipc/ipc_test_sink.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -53,7 +50,7 @@ class ScreenOrientationDispatcherHostWithSink FINAL : |
public ScreenOrientationDispatcherHost { |
public: |
explicit ScreenOrientationDispatcherHostWithSink(IPC::TestSink* sink) |
- : ScreenOrientationDispatcherHost() , sink_(sink) {} |
+ : ScreenOrientationDispatcherHost(NULL), sink_(sink) {} |
virtual bool Send(IPC::Message* message) OVERRIDE { |
return sink_->Send(message); |
@@ -68,19 +65,24 @@ class ScreenOrientationDispatcherHostWithSink FINAL : |
class ScreenOrientationDispatcherHostTest : public testing::Test { |
protected: |
virtual ScreenOrientationDispatcherHost* CreateDispatcher() { |
- return new ScreenOrientationDispatcherHost(); |
+ return new ScreenOrientationDispatcherHost(NULL); |
} |
virtual void SetUp() OVERRIDE { |
provider_ = new MockScreenOrientationProvider(); |
- dispatcher_ = CreateDispatcher(); |
+ dispatcher_.reset(CreateDispatcher()); |
dispatcher_->SetProviderForTests(provider_); |
} |
+ int routing_id() const { |
+ // We return a fake routing_id() in the context of this test. |
+ return 0; |
+ } |
+ |
// The dispatcher_ owns the provider_ but we still want to access it. |
MockScreenOrientationProvider* provider_; |
- scoped_refptr<ScreenOrientationDispatcherHost> dispatcher_; |
+ scoped_ptr<ScreenOrientationDispatcherHost> dispatcher_; |
}; |
class ScreenOrientationDispatcherHostWithSinkTest : |
@@ -123,7 +125,7 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, ProviderLock) { |
blink::WebScreenOrientationLockType orientation = orientationsToTest[i]; |
message_was_handled = dispatcher_->OnMessageReceived( |
- ScreenOrientationHostMsg_LockRequest(orientation, 0)); |
+ ScreenOrientationHostMsg_LockRequest(routing_id(), orientation, 0)); |
EXPECT_TRUE(message_was_handled); |
EXPECT_EQ(orientation, provider_->orientation()); |
@@ -134,7 +136,7 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, ProviderLock) { |
// ScreenOrientationProvider. |
TEST_F(ScreenOrientationDispatcherHostTest, ProviderUnlock) { |
bool message_was_handled = dispatcher_->OnMessageReceived( |
- ScreenOrientationHostMsg_Unlock()); |
+ ScreenOrientationHostMsg_Unlock(routing_id())); |
EXPECT_TRUE(message_was_handled); |
EXPECT_TRUE(provider_->unlock_called()); |
@@ -147,7 +149,9 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, NoProvider_LockError) { |
const int request_id = 3; |
dispatcher_->OnMessageReceived(ScreenOrientationHostMsg_LockRequest( |
- blink::WebScreenOrientationLockPortraitPrimary, request_id)); |
+ routing_id(), |
+ blink::WebScreenOrientationLockPortraitPrimary, |
+ request_id)); |
EXPECT_EQ(1u, sink().message_count()); |
@@ -168,7 +172,9 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, NoProvider_LockError) { |
TEST_F(ScreenOrientationDispatcherHostWithSinkTest, WithProvider_LockSuccess) { |
const int request_id = 42; |
dispatcher_->OnMessageReceived(ScreenOrientationHostMsg_LockRequest( |
- blink::WebScreenOrientationLockPortraitPrimary, request_id)); |
+ routing_id(), |
+ blink::WebScreenOrientationLockPortraitPrimary, |
+ request_id)); |
EXPECT_EQ(1u, sink().message_count()); |