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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 1042923003: Fail gracefully when starting Chrome with an invalid kProfileDirectory. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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/profiles/profiles_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/browser/ui/browser_tabstrip.h" 42 #include "chrome/browser/ui/browser_tabstrip.h"
43 #include "chrome/browser/ui/browser_ui_prefs.h" 43 #include "chrome/browser/ui/browser_ui_prefs.h"
44 #include "chrome/browser/ui/browser_window.h" 44 #include "chrome/browser/ui/browser_window.h"
45 #include "chrome/browser/ui/extensions/app_launch_params.h" 45 #include "chrome/browser/ui/extensions/app_launch_params.h"
46 #include "chrome/browser/ui/extensions/application_launch.h" 46 #include "chrome/browser/ui/extensions/application_launch.h"
47 #include "chrome/browser/ui/host_desktop.h" 47 #include "chrome/browser/ui/host_desktop.h"
48 #include "chrome/browser/ui/startup/startup_browser_creator.h" 48 #include "chrome/browser/ui/startup/startup_browser_creator.h"
49 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 49 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
50 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 50 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
51 #include "chrome/browser/ui/tabs/tab_strip_model.h" 51 #include "chrome/browser/ui/tabs/tab_strip_model.h"
52 #include "chrome/browser/ui/user_manager.h"
52 #include "chrome/common/chrome_switches.h" 53 #include "chrome/common/chrome_switches.h"
53 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 54 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
54 #include "chrome/common/pref_names.h" 55 #include "chrome/common/pref_names.h"
55 #include "chrome/common/url_constants.h" 56 #include "chrome/common/url_constants.h"
56 #include "chrome/grit/chromium_strings.h" 57 #include "chrome/grit/chromium_strings.h"
57 #include "chrome/grit/generated_resources.h" 58 #include "chrome/grit/generated_resources.h"
58 #include "chrome/test/base/in_process_browser_test.h" 59 #include "chrome/test/base/in_process_browser_test.h"
59 #include "chrome/test/base/test_switches.h" 60 #include "chrome/test/base/test_switches.h"
60 #include "chrome/test/base/ui_test_utils.h" 61 #include "chrome/test/base/ui_test_utils.h"
61 #include "components/app_modal/app_modal_dialog.h" 62 #include "components/app_modal/app_modal_dialog.h"
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 base::FilePath tmp_profile = temp_dir_.path().AppendASCII("tmp_profile"); 2193 base::FilePath tmp_profile = temp_dir_.path().AppendASCII("tmp_profile");
2193 tmp_profile = tmp_profile.Append(L"Test Chrome\\"); 2194 tmp_profile = tmp_profile.Append(L"Test Chrome\\");
2194 2195
2195 ASSERT_TRUE(base::CreateDirectory(tmp_profile)); 2196 ASSERT_TRUE(base::CreateDirectory(tmp_profile));
2196 command_line->AppendSwitchPath(switches::kUserDataDir, tmp_profile); 2197 command_line->AppendSwitchPath(switches::kUserDataDir, tmp_profile);
2197 } 2198 }
2198 2199
2199 base::ScopedTempDir temp_dir_; 2200 base::ScopedTempDir temp_dir_;
2200 }; 2201 };
2201 2202
2203 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
2204 // This test verifies that if Chrome is launched with an invalid
2205 // profile-directory argument, then the User Manager is shown instead.
2206 class LaunchBrowserWithInvalidProfileDirectory : public BrowserTest {
2207 public:
2208 LaunchBrowserWithInvalidProfileDirectory() {}
2209
2210 virtual void SetUpCommandLine(base::CommandLine* command_line) override {
2211 command_line->AppendSwitch(switches::kEnableNewAvatarMenu);
2212 command_line->AppendSwitchASCII(switches::kProfileDirectory,
2213 "SomeOtherProfile");
2214 }
2215
2216 base::ScopedTempDir temp_dir_;
2217 };
2218
2219 IN_PROC_BROWSER_TEST_F(LaunchBrowserWithInvalidProfileDirectory,
2220 TestUserManagerShown) {
2221 // No browser window should be open, and the User Manager should be showing.
2222 EXPECT_FALSE(browser());
2223 EXPECT_TRUE(UserManager::IsShowing());
2224 // Hide the User Manager so that the test can die.
2225 UserManager::Hide();
2226 }
2227 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
2228
2202 IN_PROC_BROWSER_TEST_F(LaunchBrowserWithTrailingSlashDatadir, 2229 IN_PROC_BROWSER_TEST_F(LaunchBrowserWithTrailingSlashDatadir,
2203 TestTrailingSlashUserDataDir) { 2230 TestTrailingSlashUserDataDir) {
2204 // Verify that the window is present. 2231 // Verify that the window is present.
2205 ASSERT_TRUE(browser()); 2232 ASSERT_TRUE(browser());
2206 ASSERT_TRUE(browser()->profile()); 2233 ASSERT_TRUE(browser()->profile());
2207 // Verify that the profile has been added correctly to the ProfileInfoCache. 2234 // Verify that the profile has been added correctly to the ProfileInfoCache.
2208 ASSERT_EQ(1u, g_browser_process->profile_manager()-> 2235 ASSERT_EQ(1u, g_browser_process->profile_manager()->
2209 GetProfileInfoCache().GetNumberOfProfiles()); 2236 GetProfileInfoCache().GetNumberOfProfiles());
2210 } 2237 }
2211 #endif // defined(OS_WIN) 2238 #endif // defined(OS_WIN)
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 #endif 2724 #endif
2698 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2725 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2699 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2726 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2700 gfx::Size exp_final_size(initial_wcv_size); 2727 gfx::Size exp_final_size(initial_wcv_size);
2701 exp_final_size.Enlarge(wcv_resize_insets.width(), 2728 exp_final_size.Enlarge(wcv_resize_insets.width(),
2702 wcv_resize_insets.height() + height_inset); 2729 wcv_resize_insets.height() + height_inset);
2703 EXPECT_EQ(exp_final_size, 2730 EXPECT_EQ(exp_final_size,
2704 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2731 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2705 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); 2732 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
2706 } 2733 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profiles_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698