| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_install_ui.h" | 9 #include "chrome/browser/extensions/extension_install_ui.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 GURL page_url = test_server()->GetURL( | 75 GURL page_url = test_server()->GetURL( |
| 76 "files/extensions/api_test/webstore_inline_install/" + page_filename); | 76 "files/extensions/api_test/webstore_inline_install/" + page_filename); |
| 77 | 77 |
| 78 GURL::Replacements replace_host; | 78 GURL::Replacements replace_host; |
| 79 replace_host.SetHostStr(domain); | 79 replace_host.SetHostStr(domain); |
| 80 return page_url.ReplaceComponents(replace_host); | 80 return page_url.ReplaceComponents(replace_host); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void RunTest(const std::string& test_function_name) { | 83 void RunTest(const std::string& test_function_name) { |
| 84 bool result = false; | 84 bool result = false; |
| 85 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(), | 85 std::string script = base::StringPrintf( |
| 86 "%s('%s')", test_function_name.c_str(), |
| 86 test_gallery_url_.c_str()); | 87 test_gallery_url_.c_str()); |
| 87 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 88 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 88 browser()->tab_strip_model()->GetActiveWebContents(), | 89 browser()->tab_strip_model()->GetActiveWebContents(), |
| 89 script, | 90 script, |
| 90 &result)); | 91 &result)); |
| 91 EXPECT_TRUE(result); | 92 EXPECT_TRUE(result); |
| 92 } | 93 } |
| 93 | 94 |
| 94 // Passes |i| to |test_function_name|, and expects that function to | 95 // Passes |i| to |test_function_name|, and expects that function to |
| 95 // return one of "FAILED", "KEEPGOING" or "DONE". KEEPGOING should be | 96 // return one of "FAILED", "KEEPGOING" or "DONE". KEEPGOING should be |
| 96 // returned if more tests remain to be run and the current test succeeded, | 97 // returned if more tests remain to be run and the current test succeeded, |
| 97 // FAILED is returned when a test fails, and DONE is returned by the last | 98 // FAILED is returned when a test fails, and DONE is returned by the last |
| 98 // test if it succeeds. | 99 // test if it succeeds. |
| 99 // This methods returns true iff there are more tests that need to be run. | 100 // This methods returns true iff there are more tests that need to be run. |
| 100 bool RunIndexedTest(const std::string& test_function_name, | 101 bool RunIndexedTest(const std::string& test_function_name, |
| 101 int i) { | 102 int i) { |
| 102 std::string result = "FAILED"; | 103 std::string result = "FAILED"; |
| 103 std::string script = StringPrintf("%s('%s', %d)", | 104 std::string script = base::StringPrintf("%s('%s', %d)", |
| 104 test_function_name.c_str(), test_gallery_url_.c_str(), i); | 105 test_function_name.c_str(), test_gallery_url_.c_str(), i); |
| 105 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 106 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 106 browser()->tab_strip_model()->GetActiveWebContents(), | 107 browser()->tab_strip_model()->GetActiveWebContents(), |
| 107 script, | 108 script, |
| 108 &result)); | 109 &result)); |
| 109 EXPECT_TRUE(result != "FAILED"); | 110 EXPECT_TRUE(result != "FAILED"); |
| 110 return result == "KEEPGOING"; | 111 return result == "KEEPGOING"; |
| 111 } | 112 } |
| 112 | 113 |
| 113 std::string test_gallery_url_; | 114 std::string test_gallery_url_; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 switches::kLimitedInstallFromWebstore, "2"); | 369 switches::kLimitedInstallFromWebstore, "2"); |
| 369 command_line->AppendSwitchASCII( | 370 command_line->AppendSwitchASCII( |
| 370 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 371 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
| 371 extensions::StartupHelper helper; | 372 extensions::StartupHelper helper; |
| 372 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), | 373 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), |
| 373 MessageLoop::QuitWhenIdleClosure()); | 374 MessageLoop::QuitWhenIdleClosure()); |
| 374 MessageLoop::current()->Run(); | 375 MessageLoop::current()->Run(); |
| 375 EXPECT_FALSE(saw_install()); | 376 EXPECT_FALSE(saw_install()); |
| 376 EXPECT_EQ(0, browser_open_count()); | 377 EXPECT_EQ(0, browser_open_count()); |
| 377 } | 378 } |
| OLD | NEW |