Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/first_run/first_run_browsertest.cc

Issue 12094026: Skip a first-run import on Mac when there is nothing left to import. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove fragile check Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/first_run/first_run.cc ('k') | chrome/browser/first_run/first_run_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
94 protected:
95 virtual void SetUp() OVERRIDE {
96 ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file_));
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
114 virtual void TearDown() OVERRIDE {
115 EXPECT_TRUE(file_util::Delete(prefs_file_, false));
116 FirstRunIntegrationBrowserTest::TearDown();
117 }
118
119 private:
120 FilePath prefs_file_;
121
122 DISALLOW_COPY_AND_ASSIGN(FirstRunMasterPrefsBrowserTest);
123 };
83 } 124 }
84 125
85 IN_PROC_BROWSER_TEST_F(FirstRunIntegrationBrowserTest, WaitForImport) { 126 IN_PROC_BROWSER_TEST_F(FirstRunIntegrationBrowserTest, WaitForImport) {
86 ASSERT_TRUE(ProfileManager::DidPerformProfileImport()); 127 ASSERT_TRUE(ProfileManager::DidPerformProfileImport());
87 } 128 }
129
130 // Test an import with all import options disabled. This is a regression test
131 // for http://crbug.com/169984 where this would cause the import process to
132 // stay running, and the NTP to be loaded with no apps.
133 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsBrowserTest,
134 ImportNothingAndShowNewTabPage) {
135 ASSERT_TRUE(ProfileManager::DidPerformProfileImport());
136 ui_test_utils::NavigateToURLWithDisposition(
137 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB,
138 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
139 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
140 EXPECT_EQ(1, tab->GetMaxPageID());
141 }
142
88 #endif // !defined(OS_CHROMEOS) 143 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run.cc ('k') | chrome/browser/first_run/first_run_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698