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

Unified Diff: content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc

Issue 327573002: Properly route screen orientation IPC messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_lock_view
Patch Set: nit Created 6 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/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..c7a91027db7fdae30d8fbaeac38057327a28f50f 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,8 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, ProviderLock) {
blink::WebScreenOrientationLockType orientation = orientationsToTest[i];
message_was_handled = dispatcher_->OnMessageReceived(
- ScreenOrientationHostMsg_LockRequest(orientation, 0));
+ ScreenOrientationHostMsg_LockRequest(routing_id(), orientation, 0),
+ NULL);
EXPECT_TRUE(message_was_handled);
EXPECT_EQ(orientation, provider_->orientation());
@@ -134,7 +137,7 @@ TEST_F(ScreenOrientationDispatcherHostWithSinkTest, ProviderLock) {
// ScreenOrientationProvider.
TEST_F(ScreenOrientationDispatcherHostTest, ProviderUnlock) {
bool message_was_handled = dispatcher_->OnMessageReceived(
- ScreenOrientationHostMsg_Unlock());
+ ScreenOrientationHostMsg_Unlock(routing_id()), NULL);
EXPECT_TRUE(message_was_handled);
EXPECT_TRUE(provider_->unlock_called());
@@ -147,7 +150,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), NULL);
EXPECT_EQ(1u, sink().message_count());
@@ -168,7 +173,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), NULL);
EXPECT_EQ(1u, sink().message_count());

Powered by Google App Engine
This is Rietveld 408576698