| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/apps/scoped_keep_alive.h" | 9 #include "chrome/browser/apps/scoped_keep_alive.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 namespace utils = extension_function_test_utils; | 35 namespace utils = extension_function_test_utils; |
| 36 | 36 |
| 37 namespace extensions { | 37 namespace extensions { |
| 38 | 38 |
| 39 PlatformAppBrowserTest::PlatformAppBrowserTest() { | 39 PlatformAppBrowserTest::PlatformAppBrowserTest() { |
| 40 ChromeAppDelegate::DisableExternalOpenForTesting(); | 40 ChromeAppDelegate::DisableExternalOpenForTesting(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 43 void PlatformAppBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 44 // Skips ExtensionApiTest::SetUpCommandLine. | 44 // Skips ExtensionApiTest::SetUpCommandLine. |
| 45 ExtensionBrowserTest::SetUpCommandLine(command_line); | 45 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 46 | 46 |
| 47 // Make event pages get suspended quicker. | 47 // Make event pages get suspended quicker. |
| 48 ProcessManager::SetEventPageIdleTimeForTesting(1000); | 48 ProcessManager::SetEventPageIdleTimeForTesting(1000); |
| 49 ProcessManager::SetEventPageSuspendingTimeForTesting(1000); | 49 ProcessManager::SetEventPageSuspendingTimeForTesting(1000); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 AppWindow* PlatformAppBrowserTest::GetFirstAppWindowForBrowser( | 53 AppWindow* PlatformAppBrowserTest::GetFirstAppWindowForBrowser( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 size_t PlatformAppBrowserTest::GetAppWindowCountForApp( | 191 size_t PlatformAppBrowserTest::GetAppWindowCountForApp( |
| 192 const std::string& app_id) { | 192 const std::string& app_id) { |
| 193 return AppWindowRegistry::Get(browser()->profile()) | 193 return AppWindowRegistry::Get(browser()->profile()) |
| 194 ->GetAppWindowsForApp(app_id) | 194 ->GetAppWindowsForApp(app_id) |
| 195 .size(); | 195 .size(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void PlatformAppBrowserTest::ClearCommandLineArgs() { | 198 void PlatformAppBrowserTest::ClearCommandLineArgs() { |
| 199 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 199 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 200 CommandLine::StringVector args = command_line->GetArgs(); | 200 base::CommandLine::StringVector args = command_line->GetArgs(); |
| 201 CommandLine::StringVector argv = command_line->argv(); | 201 base::CommandLine::StringVector argv = command_line->argv(); |
| 202 for (size_t i = 0; i < args.size(); i++) | 202 for (size_t i = 0; i < args.size(); i++) |
| 203 argv.pop_back(); | 203 argv.pop_back(); |
| 204 command_line->InitFromArgv(argv); | 204 command_line->InitFromArgv(argv); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void PlatformAppBrowserTest::SetCommandLineArg(const std::string& test_file) { | 207 void PlatformAppBrowserTest::SetCommandLineArg(const std::string& test_file) { |
| 208 ClearCommandLineArgs(); | 208 ClearCommandLineArgs(); |
| 209 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 209 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 210 base::FilePath test_doc(test_data_dir_.AppendASCII(test_file)); | 210 base::FilePath test_doc(test_data_dir_.AppendASCII(test_file)); |
| 211 test_doc = test_doc.NormalizePathSeparators(); | 211 test_doc = test_doc.NormalizePathSeparators(); |
| 212 command_line->AppendArgPath(test_doc); | 212 command_line->AppendArgPath(test_doc); |
| 213 } | 213 } |
| 214 | 214 |
| 215 AppWindow* PlatformAppBrowserTest::CreateAppWindow(const Extension* extension) { | 215 AppWindow* PlatformAppBrowserTest::CreateAppWindow(const Extension* extension) { |
| 216 return CreateAppWindowFromParams(extension, AppWindow::CreateParams()); | 216 return CreateAppWindowFromParams(extension, AppWindow::CreateParams()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 AppWindow* PlatformAppBrowserTest::CreateAppWindowFromParams( | 219 AppWindow* PlatformAppBrowserTest::CreateAppWindowFromParams( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 // Wait for the window to be opened and loaded. | 265 // Wait for the window to be opened and loaded. |
| 266 EXPECT_TRUE(loaded_listener.WaitUntilSatisfied()); | 266 EXPECT_TRUE(loaded_listener.WaitUntilSatisfied()); |
| 267 | 267 |
| 268 EXPECT_EQ(1U, GetAppWindowCount()); | 268 EXPECT_EQ(1U, GetAppWindowCount()); |
| 269 AppWindow* app_window = GetFirstAppWindow(); | 269 AppWindow* app_window = GetFirstAppWindow(); |
| 270 return app_window; | 270 return app_window; |
| 271 } | 271 } |
| 272 | 272 |
| 273 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( | 273 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( |
| 274 CommandLine* command_line) { | 274 base::CommandLine* command_line) { |
| 275 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 275 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 276 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 276 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace extensions | 279 } // namespace extensions |
| OLD | NEW |