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

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

Issue 2649823002: [ScreenOrientation] Merge ScreenOrientation into ScreenOrientationProvider. (Closed)
Patch Set: Add initial tests Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/screen_orientation_provider.h"
6
7 #include "base/optional.h"
8 #include "base/run_loop.h"
9 #include "content/public/browser/screen_orientation_delegate.h"
10 #include "content/test/test_render_view_host.h"
11 #include "content/test/test_web_contents.h"
12 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
13
14 namespace content {
leonhsl(Using Gerrit) 2017/01/23 10:11:10 Currently this file is just to show a sketch, if t
15
16 using device::mojom::ScreenOrientationLockResult;
17
18 namespace {
19
20 void LockResultCallback(base::Optional<ScreenOrientationLockResult>* out_result,
21 ScreenOrientationLockResult result) {
22 *out_result = result;
23 }
24 }
25
26 class ScreenOrientationProviderTest : public RenderViewHostImplTestHarness {
27 public:
28 ScreenOrientationProviderTest() {}
29
30 void SetUp() override { content::RenderViewHostImplTestHarness::SetUp(); }
31
32 void TearDown() override {
33 content::RenderViewHostImplTestHarness::TearDown();
34 }
35
36 // Helpers for testing ScreenOrientationProvider methods.
37 void CallLockOrientation(
38 blink::WebScreenOrientationLockType orientation,
39 const ScreenOrientationProvider::LockOrientationCallback& callback) {
40 contents()->GetScreenOrientationProvider()->LockOrientation(orientation,
41 callback);
42 }
43
44 void CallUnlockOrientation() {
45 contents()->GetScreenOrientationProvider()->UnlockOrientation();
46 }
47 };
48
49 // No ScreenOrientationDelegate.
50 TEST_F(ScreenOrientationProviderTest, NoDelegateLockOnce) {
51 base::Optional<ScreenOrientationLockResult> result;
52 CallLockOrientation(blink::WebScreenOrientationLockType::
53 WebScreenOrientationLockPortraitPrimary,
54 base::Bind(&LockResultCallback, &result));
55
56 base::RunLoop().RunUntilIdle();
57 EXPECT_EQ(ScreenOrientationLockResult::
58 SCREEN_ORIENTATION_LOCK_RESULT_ERROR_NOT_AVAILABLE,
59 *result);
60 }
61
62 // Sync ScreenOrientationDelegate, simulate on Windows and ChromeOS.
63 TEST_F(ScreenOrientationProviderTest, SyncDelegateLockOnce) {}
64
65 // Async ScreenOrientationDelegate, simulate on Android.
66 TEST_F(ScreenOrientationProviderTest, AsyncDelegateLockOnce) {}
67
68 // Sync ScreenOrientationDelegate, simulate on Windows and ChromeOS.
69 TEST_F(ScreenOrientationProviderTest, SyncDelegateLockTwice) {}
70
71 // Async ScreenOrientationDelegate, simulate on Android.
72 TEST_F(ScreenOrientationProviderTest, AsyncDelegateLockTwice) {}
73
74 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698