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

Side by Side Diff: content/browser/screen_orientation/screen_orientation_dispatcher_host_unittest.cc

Issue 292443004: Remove IPC_BEGIN_MESSAGE_MAP_EX macro since r270839 made all bad IPCs kill their child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 7 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
8 #include "content/browser/screen_orientation/screen_orientation_provider.h" 8 #include "content/browser/screen_orientation/screen_orientation_provider.h"
9 #include "content/common/screen_orientation_messages.h" 9 #include "content/common/screen_orientation_messages.h"
10 #include "content/public/test/test_utils.h" 10 #include "content/public/test/test_utils.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // The dispatcher_ owns the provider_ but we still want to access it. 57 // The dispatcher_ owns the provider_ but we still want to access it.
58 MockScreenOrientationProvider* provider_; 58 MockScreenOrientationProvider* provider_;
59 scoped_refptr<ScreenOrientationDispatcherHost> dispatcher_; 59 scoped_refptr<ScreenOrientationDispatcherHost> dispatcher_;
60 }; 60 };
61 61
62 // Test that a NULL provider is correctly handled. 62 // Test that a NULL provider is correctly handled.
63 TEST_F(ScreenOrientationDispatcherHostTest, NullProvider) { 63 TEST_F(ScreenOrientationDispatcherHostTest, NullProvider) {
64 dispatcher_->SetProviderForTests(NULL); 64 dispatcher_->SetProviderForTests(NULL);
65 65
66 bool message_was_ok = false;
67 bool message_was_handled = dispatcher_->OnMessageReceived( 66 bool message_was_handled = dispatcher_->OnMessageReceived(
68 ScreenOrientationHostMsg_Lock( 67 ScreenOrientationHostMsg_Lock(
69 blink::WebScreenOrientationLockPortraitPrimary), &message_was_ok); 68 blink::WebScreenOrientationLockPortraitPrimary));
70
71 EXPECT_TRUE(message_was_ok);
72 EXPECT_TRUE(message_was_handled); 69 EXPECT_TRUE(message_was_handled);
73 } 70 }
74 71
75 // Test that when receiving a lock message, it is correctly dispatched to the 72 // Test that when receiving a lock message, it is correctly dispatched to the
76 // ScreenOrientationProvider. 73 // ScreenOrientationProvider.
77 TEST_F(ScreenOrientationDispatcherHostTest, ProviderLock) { 74 TEST_F(ScreenOrientationDispatcherHostTest, ProviderLock) {
78 // If we change this array, update |orientationsToTestCount| below. 75 // If we change this array, update |orientationsToTestCount| below.
79 blink::WebScreenOrientationLockType orientationsToTest[] = { 76 blink::WebScreenOrientationLockType orientationsToTest[] = {
80 blink::WebScreenOrientationLockPortraitPrimary, 77 blink::WebScreenOrientationLockPortraitPrimary,
81 blink::WebScreenOrientationLockPortraitSecondary, 78 blink::WebScreenOrientationLockPortraitSecondary,
82 blink::WebScreenOrientationLockLandscapePrimary, 79 blink::WebScreenOrientationLockLandscapePrimary,
83 blink::WebScreenOrientationLockLandscapeSecondary, 80 blink::WebScreenOrientationLockLandscapeSecondary,
84 blink::WebScreenOrientationLockPortrait, 81 blink::WebScreenOrientationLockPortrait,
85 blink::WebScreenOrientationLockLandscapePrimary, 82 blink::WebScreenOrientationLockLandscapePrimary,
86 blink::WebScreenOrientationLockAny 83 blink::WebScreenOrientationLockAny
87 }; 84 };
88 85
89 // Unfortunately, initializer list constructor for std::list is not yet 86 // Unfortunately, initializer list constructor for std::list is not yet
90 // something we can use. 87 // something we can use.
91 // Keep this in sync with |orientationsToTest|. 88 // Keep this in sync with |orientationsToTest|.
92 int orientationsToTestCount = 7; 89 int orientationsToTestCount = 7;
93 90
94 for (int i = 0; i < orientationsToTestCount; ++i) { 91 for (int i = 0; i < orientationsToTestCount; ++i) {
95 bool message_was_ok = false;
96 bool message_was_handled = false; 92 bool message_was_handled = false;
97 blink::WebScreenOrientationLockType orientation = orientationsToTest[i]; 93 blink::WebScreenOrientationLockType orientation = orientationsToTest[i];
98 94
99 message_was_handled = dispatcher_->OnMessageReceived( 95 message_was_handled = dispatcher_->OnMessageReceived(
100 ScreenOrientationHostMsg_Lock(orientation), &message_was_ok); 96 ScreenOrientationHostMsg_Lock(orientation));
101 97
102 EXPECT_TRUE(message_was_ok);
103 EXPECT_TRUE(message_was_handled); 98 EXPECT_TRUE(message_was_handled);
104 EXPECT_EQ(orientation, provider_->orientation()); 99 EXPECT_EQ(orientation, provider_->orientation());
105 } 100 }
106 } 101 }
107 102
108 // Test that when receiving an unlock message, it is correctly dispatched to the 103 // Test that when receiving an unlock message, it is correctly dispatched to the
109 // ScreenOrientationProvider. 104 // ScreenOrientationProvider.
110 TEST_F(ScreenOrientationDispatcherHostTest, ProviderUnlock) { 105 TEST_F(ScreenOrientationDispatcherHostTest, ProviderUnlock) {
111 bool message_was_ok = false;
112 bool message_was_handled = dispatcher_->OnMessageReceived( 106 bool message_was_handled = dispatcher_->OnMessageReceived(
113 ScreenOrientationHostMsg_Unlock(), &message_was_ok); 107 ScreenOrientationHostMsg_Unlock());
114 108
115 EXPECT_TRUE(message_was_ok);
116 EXPECT_TRUE(message_was_handled); 109 EXPECT_TRUE(message_was_handled);
117 EXPECT_TRUE(provider_->unlock_called()); 110 EXPECT_TRUE(provider_->unlock_called());
118 } 111 }
119 112
120 } // namespace content 113 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698