OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 8 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); | 57 host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); |
58 } | 58 } |
59 | 59 |
60 void LoadPage() { | 60 void LoadPage() { |
61 StartEmbeddedTestServer(); | 61 StartEmbeddedTestServer(); |
62 const GURL url = GetURLForPath(kDomain, "/index.html"); | 62 const GURL url = GetURLForPath(kDomain, "/index.html"); |
63 ui_test_utils::NavigateToURL(browser(), url); | 63 ui_test_utils::NavigateToURL(browser(), url); |
64 } | 64 } |
65 | 65 |
66 public: | 66 public: |
67 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 67 virtual void SetUpInProcessBrowserTestFixture() override { |
68 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 68 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
69 } | 69 } |
70 }; | 70 }; |
71 | 71 |
72 IN_PROC_BROWSER_TEST_F(AutomationApiTest, TestRendererAccessibilityEnabled) { | 72 IN_PROC_BROWSER_TEST_F(AutomationApiTest, TestRendererAccessibilityEnabled) { |
73 LoadPage(); | 73 LoadPage(); |
74 | 74 |
75 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 75 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
76 content::WebContents* const tab = | 76 content::WebContents* const tab = |
77 browser()->tab_strip_model()->GetWebContentsAt(0); | 77 browser()->tab_strip_model()->GetWebContentsAt(0); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // source and target trees, respectively, and sends down the current tree for | 315 // source and target trees, respectively, and sends down the current tree for |
316 // the requested tab - tab 1 always has tree1, and tab 0 starts with tree0 | 316 // the requested tab - tab 1 always has tree1, and tab 0 starts with tree0 |
317 // and then has a series of updates intended to translate tree0 to tree1. | 317 // and then has a series of updates intended to translate tree0 to tree1. |
318 // Once all the updates have been sent, the extension asserts that both trees | 318 // Once all the updates have been sent, the extension asserts that both trees |
319 // are equivalent, and then one or both of the trees are reset to a new version. | 319 // are equivalent, and then one or both of the trees are reset to a new version. |
320 class FakeAutomationInternalEnableTabFunction | 320 class FakeAutomationInternalEnableTabFunction |
321 : public UIThreadExtensionFunction { | 321 : public UIThreadExtensionFunction { |
322 public: | 322 public: |
323 FakeAutomationInternalEnableTabFunction() {} | 323 FakeAutomationInternalEnableTabFunction() {} |
324 | 324 |
325 ExtensionFunction::ResponseAction Run() OVERRIDE { | 325 ExtensionFunction::ResponseAction Run() override { |
326 using api::automation_internal::EnableTab::Params; | 326 using api::automation_internal::EnableTab::Params; |
327 scoped_ptr<Params> params(Params::Create(*args_)); | 327 scoped_ptr<Params> params(Params::Create(*args_)); |
328 EXTENSION_FUNCTION_VALIDATE(params.get()); | 328 EXTENSION_FUNCTION_VALIDATE(params.get()); |
329 if (!params->tab_id.get()) | 329 if (!params->tab_id.get()) |
330 return RespondNow(Error("tab_id not specified")); | 330 return RespondNow(Error("tab_id not specified")); |
331 int tab_id = *params->tab_id; | 331 int tab_id = *params->tab_id; |
332 if (tab_id == 0) { | 332 if (tab_id == 0) { |
333 // tab 0 <--> tree0 | 333 // tab 0 <--> tree0 |
334 base::MessageLoop::current()->PostTask( | 334 base::MessageLoop::current()->PostTask( |
335 FROM_HERE, | 335 FROM_HERE, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 // events similarly, causing the extension to re-request the tree and going | 416 // events similarly, causing the extension to re-request the tree and going |
417 // back to step 2 again. | 417 // back to step 2 again. |
418 // 6. When tree1_version has gone through all possible values, we send a blur | 418 // 6. When tree1_version has gone through all possible values, we send a blur |
419 // event, signaling the extension to call chrome.test.succeed() and finish | 419 // event, signaling the extension to call chrome.test.succeed() and finish |
420 // the test. | 420 // the test. |
421 class FakeAutomationInternalPerformActionFunction | 421 class FakeAutomationInternalPerformActionFunction |
422 : public UIThreadExtensionFunction { | 422 : public UIThreadExtensionFunction { |
423 public: | 423 public: |
424 FakeAutomationInternalPerformActionFunction() {} | 424 FakeAutomationInternalPerformActionFunction() {} |
425 | 425 |
426 ExtensionFunction::ResponseAction Run() OVERRIDE { | 426 ExtensionFunction::ResponseAction Run() override { |
427 if (state.destroy_tree0) { | 427 if (state.destroy_tree0) { |
428 // Step 4.f: tell the extension to destroy the tree and re-request it. | 428 // Step 4.f: tell the extension to destroy the tree and re-request it. |
429 state.SendTreeDestroyedEvent(kTab0Rid, browser_context()); | 429 state.SendTreeDestroyedEvent(kTab0Rid, browser_context()); |
430 state.destroy_tree0 = false; | 430 state.destroy_tree0 = false; |
431 return RespondNow(NoArguments()); | 431 return RespondNow(NoArguments()); |
432 } | 432 } |
433 | 433 |
434 TreeSerializer* serializer0 = state.serializer0.get(); | 434 TreeSerializer* serializer0 = state.serializer0.get(); |
435 if (state.starting_node < state.tree_size) { | 435 if (state.starting_node < state.tree_size) { |
436 // As a sanity check, if the trees are not equal, assert that they are not | 436 // As a sanity check, if the trees are not equal, assert that they are not |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 "automationInternal.enableTab", | 491 "automationInternal.enableTab", |
492 FakeAutomationInternalEnableTabFunctionFactory)); | 492 FakeAutomationInternalEnableTabFunctionFactory)); |
493 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( | 493 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( |
494 "automationInternal.performAction", | 494 "automationInternal.performAction", |
495 FakeAutomationInternalPerformActionFunctionFactory)); | 495 FakeAutomationInternalPerformActionFunctionFactory)); |
496 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", | 496 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", |
497 "generated_trees.html")) << message_; | 497 "generated_trees.html")) << message_; |
498 } | 498 } |
499 | 499 |
500 } // namespace extensions | 500 } // namespace extensions |
OLD | NEW |