Chromium Code Reviews| Index: chrome/browser/extensions/clipboard_app_apitest.cc |
| diff --git a/chrome/browser/extensions/clipboard_app_apitest.cc b/chrome/browser/extensions/clipboard_app_apitest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a5e450c8052a0e187bb9cdb90949625d1998db14 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/clipboard_app_apitest.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/test/ui_test_utils.h" |
| +#include "content/browser/tab_contents/tab_contents.h" |
| +#include "googleurl/src/gurl.h" |
| +#include "net/base/mock_host_resolver.h" |
| + |
| +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ClipboardApp) { |
| + host_resolver()->AddRule("*", "127.0.0.1"); |
| + ASSERT_TRUE(StartTestServer()); |
| + |
| + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("clipboard_app"))); |
| + |
| + GURL base_url = test_server()->GetURL( |
| + "files/extensions/api_test/clipboard_app/"); |
| + GURL::Replacements replace_host; |
| + std::string host_str("localhost"); // Must stay in scope with replace_host. |
| + replace_host.SetHostStr(host_str); |
| + base_url = base_url.ReplaceComponents(replace_host); |
| + |
| + ui_test_utils::NavigateToURL(browser(), base_url.Resolve("main.html")); |
| + |
| + const wchar_t kScript[] = |
| + L"function runTest() {" |
| + L" document.body.addEventListener('copy', runTest2);" |
|
Erik does not do reviews
2011/05/20 21:49:01
This approach is a bit of a bummer since it depend
|
| + L" document.execCommand('copy');" |
| + L"}" |
| + L"function runTest2() {" |
| + L" document.body.addEventListener('paste', runTest3);" |
| + L" document.execCommand('paste');" |
| + L"}" |
| + L"function runTest3() {" |
| + L" window.domAutomationController.send(true);" |
| + L"}" |
| + L"runTest();"; |
| + |
| + bool result = false; |
| + ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| + browser()->GetSelectedTabContents()->render_view_host(), |
| + L"", |
| + kScript, |
| + &result)); |
| + EXPECT_TRUE(result); |
| +} |