X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fextensions%2Fapi%2Fautomation%2Fautomation_apitest.cc;h=470cb4d9b7c33df824600caf0fa6addbf06f81c9;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=7630d162d0863737af0b74ef9fddc8bb0ccb465e;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/extensions/api/automation/automation_apitest.cc b/src/chrome/browser/extensions/api/automation/automation_apitest.cc index 7630d16..470cb4d 100644 --- a/src/chrome/browser/extensions/api/automation/automation_apitest.cc +++ b/src/chrome/browser/extensions/api/automation/automation_apitest.cc @@ -2,17 +2,58 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "base/strings/string_number_conversions.h" #include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { +namespace { +static const char kDomain[] = "a.com"; +static const char kSitesDir[] = "automation/sites"; +static const char kGotTree[] = "got_tree"; +} // anonymous namespace + class AutomationApiTest : public ExtensionApiTest { + protected: + GURL GetURLForPath(const std::string& host, const std::string& path) { + std::string port = base::IntToString(embedded_test_server()->port()); + GURL::Replacements replacements; + replacements.SetHostStr(host); + replacements.SetPortStr(port); + GURL url = + embedded_test_server()->GetURL(path).ReplaceComponents(replacements); + return url; + } + + void StartEmbeddedTestServer() { + base::FilePath test_data; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); + embedded_test_server()->ServeFilesFromDirectory( + test_data.AppendASCII("extensions/api_test") + .AppendASCII(kSitesDir)); + ASSERT_TRUE(ExtensionApiTest::StartEmbeddedTestServer()); + host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); + } + + void LoadPage() { + StartEmbeddedTestServer(); + const GURL url = GetURLForPath(kDomain, "/index.html"); + ui_test_utils::NavigateToURL(browser(), url); + } + public: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { ExtensionApiTest::SetUpCommandLine(command_line); @@ -24,7 +65,9 @@ class AutomationApiTest : public ExtensionApiTest { } }; -IN_PROC_BROWSER_TEST_F(AutomationApiTest, SanityCheck) { +IN_PROC_BROWSER_TEST_F(AutomationApiTest, TestRendererAccessibilityEnabled) { + LoadPage(); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); content::WebContents* const tab = browser()->tab_strip_model()->GetWebContentsAt(0); @@ -35,7 +78,11 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, SanityCheck) { ASSERT_FALSE(rwh->IsFullAccessibilityModeForTesting()); ASSERT_FALSE(rwh->IsTreeOnlyAccessibilityModeForTesting()); - ASSERT_TRUE(RunComponentExtensionTest("automation/sanity_check")) << message_; + base::FilePath extension_path = + test_data_dir_.AppendASCII("automation/basic"); + ExtensionTestMessageListener got_tree(kGotTree, false /* no reply */); + LoadExtension(extension_path); + ASSERT_TRUE(got_tree.WaitUntilSatisfied()); rwh = tab->GetRenderWidgetHostView()->GetRenderWidgetHost(); ASSERT_NE((content::RenderWidgetHost*)NULL, rwh) @@ -44,4 +91,41 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, SanityCheck) { ASSERT_TRUE(rwh->IsTreeOnlyAccessibilityModeForTesting()); } +// TODO(dtseng): See crbug.com/360297. +#if defined(OS_MACOSX) +#define MAYBE_SanityCheck DISABLED_SanityCheck +#else +#define MAYBE_SanityCheck SanityCheck +#endif // defined(OS_MACOSX) +IN_PROC_BROWSER_TEST_F(AutomationApiTest, MAYBE_SanityCheck) { + StartEmbeddedTestServer(); + ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "sanity_check.html")) + << message_; +} + +IN_PROC_BROWSER_TEST_F(AutomationApiTest, Events) { + LoadPage(); + ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "events.html")) + << message_; +} + +IN_PROC_BROWSER_TEST_F(AutomationApiTest, Actions) { + LoadPage(); + ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "actions.html")) + << message_; +} + +IN_PROC_BROWSER_TEST_F(AutomationApiTest, Location) { + LoadPage(); + ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "location.html")) + << message_; +} + +#if defined(OS_CHROMEOS) +IN_PROC_BROWSER_TEST_F(AutomationApiTest, Desktop) { + ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "desktop.html")) + << message_; +} +#endif + } // namespace extensions