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

Side by Side Diff: chrome/browser/chrome_main_browsertest.cc

Issue 12662033: Show user data dialog earlier on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a browser test as suggested by Scott. Created 7 years, 9 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 | Annotate | Revision Log
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 "chrome/test/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/user_data_dir_dialog.h"
15 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
21 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 content::NotificationService::AllSources()); 130 content::NotificationService::AllSources());
130 Relaunch(new_command_line); 131 Relaunch(new_command_line);
131 tab_observer.Wait(); 132 tab_observer.Wait();
132 133
133 // There should be one normal and one incognito window now. 134 // There should be one normal and one incognito window now.
134 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); 135 ASSERT_EQ(2u, chrome::GetTotalBrowserCount());
135 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); 136 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type));
136 } 137 }
137 138
138 #endif // !OS_MACOSX 139 #endif // !OS_MACOSX
140
141 // These tests only apply to the Windows version; see chrome_browser_main.cc:
142 // function GetUserDataDir() for details.
143 #if defined(OS_WIN)
144 class ChromeMainUserDataDirTest : public InProcessBrowserTest {
145 public:
146 ChromeMainUserDataDirTest(): callback_invoked_(false) {}
147
148 bool is_callback_invoked() { return callback_invoked_; }
149 void ShowUserDataDirDialog() {
150 // Set callback invoked flag and restore the correct user data dir.
151 callback_invoked_ = true;
152 PathService::Override(chrome::DIR_USER_DATA, user_data_dir_);
153 }
154
155 protected:
156 base::FilePath user_data_dir_;
157 bool callback_invoked_;
158
159 virtual void SetUp() OVERRIDE {
160 InProcessBrowserTest::SetUp();
161
162 // Save the actual user data dir.
163 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
164
165 // Override user data dir to a bogus value. Make sure to set |create| flag
166 // to false so that PathService::OverrideAndCreateIfNeeded does not create
167 // a folder at this path.
168 base::FilePath bogus_user_data_dir("/bogus/should/not/exist");
169 PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA,
170 bogus_user_data_dir,
171 false);
172
173 // Install custom ShowUserDataDirDialog callback.
174 chrome::InstallCustomShowUserDataDirDialogCallbackForTest(
175 base::Bind(&ChromeMainUserDataDirTest::ShowUserDataDirDialog, this));
176 }
177 };
178
179 IN_PROC_BROWSER_TEST_F(ChromeMainUserDataDirTest, BogusUserDataDir) {
180 // The ShowUserDataDirDialog should have been invoked and we did not crash.
181 ASSERT_TRUE(is_callback_invoked());
182 }
183 #endif // OS_WIN
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698