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

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

Issue 2682643002: [ScreenOrientation] Hide ScreenOrientationProvider inside WebContentsImpl. (Closed)
Patch Set: Rebase only Created 3 years, 10 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/public/browser/screen_orientation_provider.h" 5 #include "content/browser/screen_orientation/screen_orientation_provider.h"
6 6
7 #include "base/optional.h" 7 #include "base/optional.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/public/browser/screen_orientation_delegate.h" 10 #include "content/public/browser/screen_orientation_delegate.h"
11 #include "content/public/browser/web_contents_delegate.h" 11 #include "content/public/browser/web_contents_delegate.h"
12 #include "content/test/test_render_view_host.h" 12 #include "content/test/test_render_view_host.h"
13 #include "content/test/test_web_contents.h" 13 #include "content/test/test_web_contents.h"
14 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 14 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
15 15
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void SetUp() override { 93 void SetUp() override {
94 content::RenderViewHostImplTestHarness::SetUp(); 94 content::RenderViewHostImplTestHarness::SetUp();
95 95
96 contents()->SetDelegate(&wc_delegate_); 96 contents()->SetDelegate(&wc_delegate_);
97 } 97 }
98 98
99 // Helpers for testing ScreenOrientationProvider methods. 99 // Helpers for testing ScreenOrientationProvider methods.
100 void CallLockAndGetResult( 100 void CallLockAndGetResult(
101 blink::WebScreenOrientationLockType orientation, 101 blink::WebScreenOrientationLockType orientation,
102 base::Optional<ScreenOrientationLockResult>* out_result) { 102 base::Optional<ScreenOrientationLockResult>* out_result) {
103 contents()->GetScreenOrientationProvider()->LockOrientation( 103 contents()->GetScreenOrientationProviderForTesting()->LockOrientation(
104 orientation, base::Bind(&LockResultCallback, out_result)); 104 orientation, base::Bind(&LockResultCallback, out_result));
105 105
106 base::RunLoop().RunUntilIdle(); 106 base::RunLoop().RunUntilIdle();
107 } 107 }
108 108
109 void CallUnlock() { 109 void CallUnlock() {
110 contents()->GetScreenOrientationProvider()->UnlockOrientation(); 110 contents()->GetScreenOrientationProviderForTesting()->UnlockOrientation();
111 } 111 }
112 112
113 private: 113 private:
114 FakeWebContentsDelegate wc_delegate_; 114 FakeWebContentsDelegate wc_delegate_;
115 }; 115 };
116 116
117 // Lock operation is not available. 117 // Lock operation is not available.
118 TEST_F(ScreenOrientationProviderTest, DelegateNotAvailableLockOnce) { 118 TEST_F(ScreenOrientationProviderTest, DelegateNotAvailableLockOnce) {
119 // No ScreenOrientationDelegate. 119 // No ScreenOrientationDelegate.
120 base::Optional<ScreenOrientationLockResult> result_1; 120 base::Optional<ScreenOrientationLockResult> result_1;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 contents()->NavigateAndCommit(another_url); 334 contents()->NavigateAndCommit(another_url);
335 // The pending lock request is cancelled. 335 // The pending lock request is cancelled.
336 EXPECT_EQ(ScreenOrientationLockResult:: 336 EXPECT_EQ(ScreenOrientationLockResult::
337 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED, 337 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
338 result); 338 result);
339 // Delegate did apply unlock once. 339 // Delegate did apply unlock once.
340 EXPECT_EQ(1, delegate.unlock_count()); 340 EXPECT_EQ(1, delegate.unlock_count());
341 } 341 }
342 342
343 } // namespace content 343 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/screen_orientation/screen_orientation_provider.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698