Chromium Code Reviews| Index: content/browser/keyboard_lock/keyboard_lock_browsertest.cc |
| diff --git a/content/browser/keyboard_lock/keyboard_lock_browsertest.cc b/content/browser/keyboard_lock/keyboard_lock_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1950d7681300801cb723649c0049aa7686a65bdc |
| --- /dev/null |
| +++ b/content/browser/keyboard_lock/keyboard_lock_browsertest.cc |
| @@ -0,0 +1,68 @@ |
| +// 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 <stdint.h> |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file_path.h" |
| +#include "base/location.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/test/thread_test_helper.h" |
| +#include "content/browser/web_contents/web_contents_impl.h" |
| +#include "content/public/browser/browser_context.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/storage_partition.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "content/public/test/content_browser_test.h" |
| +#include "content/public/test/content_browser_test_utils.h" |
| +#include "content/shell/browser/shell.h" |
| + |
| +namespace content { |
| + |
| +// This browser test is aimed towards exercising the File System API bindings |
| +// and the actual implementation that lives in the browser side. |
| +class KeyboardLockBrowserTest : public ContentBrowserTest { |
| + public: |
| + KeyboardLockBrowserTest() = default; |
| + |
| + void SimpleTest(const GURL& test_url, const std::string& expected_result) { |
| + // The test page will perform tests on keyboard lock APIs, then write the |
| + // result into an element with id "result". |
| + Shell* const the_browser = shell(); |
| + |
| + VLOG(0) << "Navigating to URL and blocking."; |
| + ASSERT_TRUE(NavigateToURL(the_browser, test_url)); |
| + VLOG(0) << "Navigation done."; |
| + std::string result; |
| + ASSERT_TRUE(ExecuteScriptAndExtractString( |
| + the_browser, |
| + "window.domAutomationController.send(" |
| + "document.getElementById(\'result\').innerHTML);", |
| + &result)); |
| + ASSERT_EQ(result, expected_result); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, RequestTest) { |
| + // TODO: This test should receive "Succeeded" once the implementation in |
|
whywhat
2017/04/11 14:52:33
nit: TODO(username) here and below
Hzj_jie
2017/04/12 02:51:05
Done.
|
| + // RenderFrameHostImpl has been finished. |
| + SimpleTest(GetTestUrl("keyboard_lock", "request_keylock.html"), |
| + "Failed: Unsupported"); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, CancelTest) { |
| + SimpleTest(GetTestUrl("keyboard_lock", "cancel_keylock.html"), "Succeeded"); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, RequestTwiceTest) { |
| + // TODO: This test should receive "Succeeded" once the implementation in |
| + // RenderFrameHostImpl has been finished. |
| + SimpleTest(GetTestUrl("keyboard_lock", "request_keylock_twice.html"), |
| + "Failed: Last requestKeyLock() has not finished yet.\n" |
| + "Failed: Unsupported\n"); |
| +} |
| + |
| +} // namespace content |