Chromium Code Reviews| Index: content/browser/screen_orientation/screen_orientation_provider_unittest.cc |
| diff --git a/content/browser/screen_orientation/screen_orientation_provider_unittest.cc b/content/browser/screen_orientation/screen_orientation_provider_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3e6e187e769a10daa5fc6f06386b07414e35d6b5 |
| --- /dev/null |
| +++ b/content/browser/screen_orientation/screen_orientation_provider_unittest.cc |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/public/browser/screen_orientation_provider.h" |
| + |
| +#include "base/optional.h" |
| +#include "base/run_loop.h" |
| +#include "content/public/browser/screen_orientation_delegate.h" |
| +#include "content/test/test_render_view_host.h" |
| +#include "content/test/test_web_contents.h" |
| +#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h" |
| + |
| +namespace content { |
|
leonhsl(Using Gerrit)
2017/01/23 10:11:10
Currently this file is just to show a sketch, if t
|
| + |
| +using device::mojom::ScreenOrientationLockResult; |
| + |
| +namespace { |
| + |
| +void LockResultCallback(base::Optional<ScreenOrientationLockResult>* out_result, |
| + ScreenOrientationLockResult result) { |
| + *out_result = result; |
| +} |
| +} |
| + |
| +class ScreenOrientationProviderTest : public RenderViewHostImplTestHarness { |
| + public: |
| + ScreenOrientationProviderTest() {} |
| + |
| + void SetUp() override { content::RenderViewHostImplTestHarness::SetUp(); } |
| + |
| + void TearDown() override { |
| + content::RenderViewHostImplTestHarness::TearDown(); |
| + } |
| + |
| + // Helpers for testing ScreenOrientationProvider methods. |
| + void CallLockOrientation( |
| + blink::WebScreenOrientationLockType orientation, |
| + const ScreenOrientationProvider::LockOrientationCallback& callback) { |
| + contents()->GetScreenOrientationProvider()->LockOrientation(orientation, |
| + callback); |
| + } |
| + |
| + void CallUnlockOrientation() { |
| + contents()->GetScreenOrientationProvider()->UnlockOrientation(); |
| + } |
| +}; |
| + |
| +// No ScreenOrientationDelegate. |
| +TEST_F(ScreenOrientationProviderTest, NoDelegateLockOnce) { |
| + base::Optional<ScreenOrientationLockResult> result; |
| + CallLockOrientation(blink::WebScreenOrientationLockType:: |
| + WebScreenOrientationLockPortraitPrimary, |
| + base::Bind(&LockResultCallback, &result)); |
| + |
| + base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(ScreenOrientationLockResult:: |
| + SCREEN_ORIENTATION_LOCK_RESULT_ERROR_NOT_AVAILABLE, |
| + *result); |
| +} |
| + |
| +// Sync ScreenOrientationDelegate, simulate on Windows and ChromeOS. |
| +TEST_F(ScreenOrientationProviderTest, SyncDelegateLockOnce) {} |
| + |
| +// Async ScreenOrientationDelegate, simulate on Android. |
| +TEST_F(ScreenOrientationProviderTest, AsyncDelegateLockOnce) {} |
| + |
| +// Sync ScreenOrientationDelegate, simulate on Windows and ChromeOS. |
| +TEST_F(ScreenOrientationProviderTest, SyncDelegateLockTwice) {} |
| + |
| +// Async ScreenOrientationDelegate, simulate on Android. |
| +TEST_F(ScreenOrientationProviderTest, AsyncDelegateLockTwice) {} |
| + |
| +} // namespace content |