OLD | NEW |
---|---|
(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 <stdint.h> | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/files/file_path.h" | |
9 #include "base/location.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/single_thread_task_runner.h" | |
12 #include "base/test/thread_test_helper.h" | |
13 #include "content/browser/web_contents/web_contents_impl.h" | |
14 #include "content/public/browser/browser_context.h" | |
15 #include "content/public/browser/browser_thread.h" | |
16 #include "content/public/browser/storage_partition.h" | |
17 #include "content/public/common/content_switches.h" | |
18 #include "content/public/test/browser_test_utils.h" | |
19 #include "content/public/test/content_browser_test.h" | |
20 #include "content/public/test/content_browser_test_utils.h" | |
21 #include "content/shell/browser/shell.h" | |
22 | |
23 namespace content { | |
24 | |
25 // This browser test is aimed towards exercising the File System API bindings | |
whywhat
2017/04/12 16:02:12
nit: update comment
Hzj_jie
2017/04/13 00:38:53
Done.
| |
26 // and the actual implementation that lives in the browser side. | |
27 class KeyboardLockBrowserTest : public ContentBrowserTest { | |
28 public: | |
29 KeyboardLockBrowserTest() = default; | |
30 | |
31 void SimpleTest(const std::string& function_name, | |
32 const std::string& expected_result) { | |
33 // The test page will perform tests on keyboard lock APIs, then write the | |
34 // result into an element with id "result". | |
35 Shell* const the_browser = shell(); | |
36 | |
37 VLOG(0) << "Navigating to URL and blocking."; | |
38 ASSERT_TRUE(NavigateToURL( | |
39 the_browser, GetTestUrl("keyboard_lock", "keyboard_lock.html"))); | |
40 VLOG(0) << "Navigation done."; | |
41 std::string result; | |
42 ASSERT_TRUE(ExecuteScriptAndExtractString(the_browser, | |
43 function_name + "();", &result)); | |
44 ASSERT_EQ(result, expected_result); | |
45 } | |
46 | |
47 protected: | |
48 void SetUpCommandLine(base::CommandLine* command_line) override { | |
49 ContentBrowserTest::SetUpCommandLine(command_line); | |
50 command_line->AppendSwitchASCII("--enable-blink-features", "KeyboardLock"); | |
51 } | |
52 }; | |
53 | |
54 IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, RequestTest) { | |
55 // TODO(zijiehe): This test should receive "Succeeded" once the implementation | |
56 // in RenderFrameHostImpl has been finished. | |
57 SimpleTest("testRequestKeyLock", "Failed: Unsupported"); | |
58 } | |
59 | |
60 IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, CancelTest) { | |
61 SimpleTest("testCancelKeyLock", "Succeeded"); | |
62 } | |
63 | |
64 IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, RequestTwiceTest) { | |
65 // TODO(zijiehe): This test should receive "Succeeded" once the implementation | |
whywhat
2017/04/12 16:02:12
nit: I'd say you have a layout test for this and t
Hzj_jie
2017/04/13 00:38:54
If it's not a must-have, I would remove this file
whywhat
2017/04/13 02:34:36
I think it's okay to add browser tests later that
Hzj_jie
2017/04/13 22:24:24
:)
| |
66 // in RenderFrameHostImpl has been finished. | |
67 SimpleTest("testRequestKeyLockTwice", | |
68 "Failed: Last requestKeyLock() has not finished yet.\n" | |
69 "Failed: Unsupported\n"); | |
70 } | |
71 | |
72 } // namespace content | |
OLD | NEW |