| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotRequested) { | 153 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotRequested) { |
| 154 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", | 154 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", |
| 155 "desktop_not_requested.html")) << message_; | 155 "desktop_not_requested.html")) << message_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopActions) { | 158 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopActions) { |
| 159 ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "actions.html")) | 159 ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "actions.html")) |
| 160 << message_; | 160 << message_; |
| 161 } | 161 } |
| 162 |
| 163 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopLoadTabs) { |
| 164 ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "load_tabs.html")) |
| 165 << message_; |
| 166 } |
| 162 #else | 167 #else |
| 163 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotSupported) { | 168 IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotSupported) { |
| 164 ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", | 169 ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", |
| 165 "desktop_not_supported.html")) << message_; | 170 "desktop_not_supported.html")) << message_; |
| 166 } | 171 } |
| 167 #endif | 172 #endif |
| 168 | 173 |
| 169 IN_PROC_BROWSER_TEST_F(AutomationApiTest, CloseTab) { | 174 IN_PROC_BROWSER_TEST_F(AutomationApiTest, CloseTab) { |
| 170 StartEmbeddedTestServer(); | 175 StartEmbeddedTestServer(); |
| 171 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "close_tab.html")) | 176 ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "close_tab.html")) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (!params->tab_id.get()) | 334 if (!params->tab_id.get()) |
| 330 return RespondNow(Error("tab_id not specified")); | 335 return RespondNow(Error("tab_id not specified")); |
| 331 int tab_id = *params->tab_id; | 336 int tab_id = *params->tab_id; |
| 332 if (tab_id == 0) { | 337 if (tab_id == 0) { |
| 333 // tab 0 <--> tree0 | 338 // tab 0 <--> tree0 |
| 334 base::MessageLoop::current()->PostTask( | 339 base::MessageLoop::current()->PostTask( |
| 335 FROM_HERE, | 340 FROM_HERE, |
| 336 base::Bind(&TreeSerializationState::InitializeTree0, | 341 base::Bind(&TreeSerializationState::InitializeTree0, |
| 337 base::Unretained(&state), | 342 base::Unretained(&state), |
| 338 base::Unretained(browser_context()))); | 343 base::Unretained(browser_context()))); |
| 339 return RespondNow( | 344 // TODO(dtseng): Need to rewrite this test in terms of tree ids... |
| 340 ArgumentList(api::automation_internal::EnableTab::Results::Create( | 345 return RespondNow(ArgumentList( |
| 341 kPid, kTab0Rid))); | 346 api::automation_internal::EnableTab::Results::Create(0))); |
| 342 } | 347 } |
| 343 if (tab_id == 1) { | 348 if (tab_id == 1) { |
| 344 // tab 1 <--> tree1 | 349 // tab 1 <--> tree1 |
| 345 base::MessageLoop::current()->PostTask( | 350 base::MessageLoop::current()->PostTask( |
| 346 FROM_HERE, | 351 FROM_HERE, |
| 347 base::Bind(&TreeSerializationState::InitializeTree1, | 352 base::Bind(&TreeSerializationState::InitializeTree1, |
| 348 base::Unretained(&state), | 353 base::Unretained(&state), |
| 349 base::Unretained(browser_context()))); | 354 base::Unretained(browser_context()))); |
| 350 return RespondNow( | 355 return RespondNow(ArgumentList( |
| 351 ArgumentList(api::automation_internal::EnableTab::Results::Create( | 356 api::automation_internal::EnableTab::Results::Create(0))); |
| 352 kPid, kTab1Rid))); | |
| 353 } | 357 } |
| 354 return RespondNow(Error("Unrecognised tab_id")); | 358 return RespondNow(Error("Unrecognised tab_id")); |
| 355 } | 359 } |
| 356 }; | 360 }; |
| 357 | 361 |
| 358 // Factory method for use in OverrideFunction() | 362 // Factory method for use in OverrideFunction() |
| 359 ExtensionFunction* FakeAutomationInternalEnableTabFunctionFactory() { | 363 ExtensionFunction* FakeAutomationInternalEnableTabFunctionFactory() { |
| 360 return new FakeAutomationInternalEnableTabFunction(); | 364 return new FakeAutomationInternalEnableTabFunction(); |
| 361 } | 365 } |
| 362 | 366 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 "automationInternal.enableTab", | 495 "automationInternal.enableTab", |
| 492 FakeAutomationInternalEnableTabFunctionFactory)); | 496 FakeAutomationInternalEnableTabFunctionFactory)); |
| 493 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( | 497 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( |
| 494 "automationInternal.performAction", | 498 "automationInternal.performAction", |
| 495 FakeAutomationInternalPerformActionFunctionFactory)); | 499 FakeAutomationInternalPerformActionFunctionFactory)); |
| 496 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", | 500 ASSERT_TRUE(RunExtensionSubtest("automation/tests/generated", |
| 497 "generated_trees.html")) << message_; | 501 "generated_trees.html")) << message_; |
| 498 } | 502 } |
| 499 | 503 |
| 500 } // namespace extensions | 504 } // namespace extensions |
| OLD | NEW |