Chromium Code Reviews| 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/utf_string_conversions.h" | |
| 6 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/extensions/component_loader.h" | 8 #include "chrome/browser/extensions/component_loader.h" |
| 8 #include "chrome/browser/first_run/first_run.h" | 9 #include "chrome/browser/first_run/first_run.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/browser.h" | |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 11 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | |
| 19 #include "content/public/browser/web_contents.h" | |
| 14 #include "content/public/test/test_launcher.h" | 20 #include "content/public/test/test_launcher.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 22 |
| 17 typedef InProcessBrowserTest FirstRunBrowserTest; | 23 typedef InProcessBrowserTest FirstRunBrowserTest; |
| 18 | 24 |
| 19 IN_PROC_BROWSER_TEST_F(FirstRunBrowserTest, SetShowFirstRunBubblePref) { | 25 IN_PROC_BROWSER_TEST_F(FirstRunBrowserTest, SetShowFirstRunBubblePref) { |
| 20 EXPECT_TRUE(g_browser_process->local_state()->FindPreference( | 26 EXPECT_TRUE(g_browser_process->local_state()->FindPreference( |
| 21 prefs::kShowFirstRunBubbleOption)); | 27 prefs::kShowFirstRunBubbleOption)); |
| 22 EXPECT_EQ(first_run::FIRST_RUN_BUBBLE_DONT_SHOW, | 28 EXPECT_EQ(first_run::FIRST_RUN_BUBBLE_DONT_SHOW, |
| 23 g_browser_process->local_state()->GetInteger( | 29 g_browser_process->local_state()->GetInteger( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); | 79 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 74 | 80 |
| 75 // The forked import process should run BrowserMain. | 81 // The forked import process should run BrowserMain. |
| 76 CommandLine import_arguments((CommandLine::NoProgram())); | 82 CommandLine import_arguments((CommandLine::NoProgram())); |
| 77 import_arguments.AppendSwitch(content::kLaunchAsBrowser); | 83 import_arguments.AppendSwitch(content::kLaunchAsBrowser); |
| 78 first_run::SetExtraArgumentsForImportProcess(import_arguments); | 84 first_run::SetExtraArgumentsForImportProcess(import_arguments); |
| 79 } | 85 } |
| 80 private: | 86 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(FirstRunIntegrationBrowserTest); | 87 DISALLOW_COPY_AND_ASSIGN(FirstRunIntegrationBrowserTest); |
| 82 }; | 88 }; |
| 89 | |
| 90 class FirstRunMasterPrefsBrowserTest : public FirstRunIntegrationBrowserTest { | |
| 91 public: | |
| 92 FirstRunMasterPrefsBrowserTest() {} | |
| 93 protected: | |
| 94 virtual void SetUp() OVERRIDE { | |
| 95 FilePath prefs_file; | |
| 96 ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file)); | |
|
cpu_(ooo_6.6-7.5)
2013/01/30 21:00:53
who deletes this temporary file?
tapted
2013/01/31 00:47:16
Fixed (how did I miss that..).
| |
| 97 // TODO(tapted): Make this reusable. | |
| 98 const char text[] = | |
| 99 "{\n" | |
| 100 " \"distribution\": {\n" | |
| 101 " \"import_bookmarks\": false,\n" | |
| 102 " \"import_history\": false,\n" | |
| 103 " \"import_home_page\": false,\n" | |
| 104 " \"import_search_engine\": false\n" | |
| 105 " }\n" | |
| 106 "}\n"; | |
| 107 EXPECT_TRUE(file_util::WriteFile(prefs_file, text, strlen(text))); | |
| 108 first_run::SetMasterPrefsPathForTesting(prefs_file); | |
| 109 | |
| 110 // This invokes BrowserMain, and does the import, so must be done last. | |
| 111 FirstRunIntegrationBrowserTest::SetUp(); | |
| 112 } | |
| 113 private: | |
| 114 DISALLOW_COPY_AND_ASSIGN(FirstRunMasterPrefsBrowserTest); | |
| 115 }; | |
| 83 } | 116 } |
| 84 | 117 |
| 85 IN_PROC_BROWSER_TEST_F(FirstRunIntegrationBrowserTest, WaitForImport) { | 118 IN_PROC_BROWSER_TEST_F(FirstRunIntegrationBrowserTest, WaitForImport) { |
| 86 ASSERT_TRUE(ProfileManager::DidPerformProfileImport()); | 119 ASSERT_TRUE(ProfileManager::DidPerformProfileImport()); |
| 87 } | 120 } |
| 121 | |
| 122 // Test an import with all import options disabled. This is a regression test | |
| 123 // for http://crbug.com/169984 where this would cause the import process to | |
| 124 // stay running, and the NTP to be loaded with no apps. | |
| 125 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsBrowserTest, | |
| 126 ImportNothingAndShowNewTabPage) { | |
| 127 ASSERT_TRUE(ProfileManager::DidPerformProfileImport()); | |
| 128 ui_test_utils::NavigateToURLWithDisposition( | |
| 129 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, | |
| 130 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 131 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); | |
| 132 EXPECT_EQ(1, tab->GetMaxPageID()); | |
| 133 | |
| 134 // "Web Store" appears 3 times on the NTP. One is a component extension that | |
| 135 // is only added after the import process is complete. | |
|
cpu_(ooo_6.6-7.5)
2013/01/30 21:00:53
this test seems very fagile. There must be a bette
tapted
2013/01/31 00:47:16
This last step is more to address the specific obs
| |
| 136 EXPECT_EQ( | |
| 137 ui_test_utils::FindInPage( | |
| 138 tab, ASCIIToUTF16("Web Store"), true, false, NULL, NULL), | |
| 139 3); | |
| 140 } | |
| 141 | |
| 88 #endif // !defined(OS_CHROMEOS) | 142 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |