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

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

Issue 12315094: Remove kDefaultHostDesktopType from browser_finder.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix StartupBrowserCreatorTest.ProfilesWithoutPagesNotLaunched 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"
(...skipping 23 matching lines...) Expand all
34 void Relaunch(const CommandLine& new_command_line) { 34 void Relaunch(const CommandLine& new_command_line) {
35 base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL); 35 base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
36 } 36 }
37 }; 37 };
38 38
39 // Make sure that the second invocation creates a new window. 39 // Make sure that the second invocation creates a new window.
40 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunch) { 40 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunch) {
41 ui_test_utils::BrowserAddedObserver observer; 41 ui_test_utils::BrowserAddedObserver observer;
42 Relaunch(GetCommandLineForRelaunch()); 42 Relaunch(GetCommandLineForRelaunch());
43 observer.WaitForSingleNewBrowser(); 43 observer.WaitForSingleNewBrowser();
44 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); 44 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
45 browser()->host_desktop_type()));
45 } 46 }
46 47
47 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { 48 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) {
48 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( 49 base::FilePath test_file_path = ui_test_utils::GetTestFilePath(
49 base::FilePath(), base::FilePath().AppendASCII("empty.html")); 50 base::FilePath(), base::FilePath().AppendASCII("empty.html"));
50 CommandLine new_command_line(GetCommandLineForRelaunch()); 51 CommandLine new_command_line(GetCommandLineForRelaunch());
51 new_command_line.AppendArgPath(test_file_path); 52 new_command_line.AppendArgPath(test_file_path);
52 content::WindowedNotificationObserver observer( 53 content::WindowedNotificationObserver observer(
53 chrome::NOTIFICATION_TAB_ADDED, 54 chrome::NOTIFICATION_TAB_ADDED,
54 content::NotificationService::AllSources()); 55 content::NotificationService::AllSources());
55 Relaunch(new_command_line); 56 Relaunch(new_command_line);
56 observer.Wait(); 57 observer.Wait();
57 58
58 GURL url = net::FilePathToFileURL(test_file_path); 59 GURL url = net::FilePathToFileURL(test_file_path);
59 content::WebContents* tab = 60 content::WebContents* tab =
60 browser()->tab_strip_model()->GetActiveWebContents(); 61 browser()->tab_strip_model()->GetActiveWebContents();
61 ASSERT_EQ(url, tab->GetController().GetActiveEntry()->GetVirtualURL()); 62 ASSERT_EQ(url, tab->GetController().GetActiveEntry()->GetVirtualURL());
62 } 63 }
63 64
64 // ChromeMainTest.SecondLaunchWithIncognitoUrl is flaky on Win and Linux. 65 // ChromeMainTest.SecondLaunchWithIncognitoUrl is flaky on Win and Linux.
65 // http://crbug.com/130395 66 // http://crbug.com/130395
66 #if defined(OS_WIN) || defined(OS_LINUX) 67 #if defined(OS_WIN) || defined(OS_LINUX)
67 #define MAYBE_SecondLaunchWithIncognitoUrl DISABLED_SecondLaunchWithIncognitoUrl 68 #define MAYBE_SecondLaunchWithIncognitoUrl DISABLED_SecondLaunchWithIncognitoUrl
68 #else 69 #else
69 #define MAYBE_SecondLaunchWithIncognitoUrl SecondLaunchWithIncognitoUrl 70 #define MAYBE_SecondLaunchWithIncognitoUrl SecondLaunchWithIncognitoUrl
70 #endif 71 #endif
71 72
72 IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { 73 IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) {
73 // We should start with one normal window. 74 // We should start with one normal window.
74 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); 75 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(),
76 browser()->host_desktop_type()));
75 77
76 // Run with --incognito switch and an URL specified. 78 // Run with --incognito switch and an URL specified.
77 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( 79 base::FilePath test_file_path = ui_test_utils::GetTestFilePath(
78 base::FilePath(), base::FilePath().AppendASCII("empty.html")); 80 base::FilePath(), base::FilePath().AppendASCII("empty.html"));
79 CommandLine new_command_line(GetCommandLineForRelaunch()); 81 CommandLine new_command_line(GetCommandLineForRelaunch());
80 new_command_line.AppendSwitch(switches::kIncognito); 82 new_command_line.AppendSwitch(switches::kIncognito);
81 new_command_line.AppendArgPath(test_file_path); 83 new_command_line.AppendArgPath(test_file_path);
82 84
83 Relaunch(new_command_line); 85 Relaunch(new_command_line);
84 86
85 // There should be one normal and one incognito window now. 87 // There should be one normal and one incognito window now.
86 ui_test_utils::BrowserAddedObserver observer; 88 ui_test_utils::BrowserAddedObserver observer;
87 Relaunch(new_command_line); 89 Relaunch(new_command_line);
88 observer.WaitForSingleNewBrowser(); 90 observer.WaitForSingleNewBrowser();
89 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); 91 ASSERT_EQ(2u, chrome::GetTotalBrowserCount());
90 92
91 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); 93 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(),
94 browser()->host_desktop_type()));
92 } 95 }
93 96
94 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { 97 IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) {
95 // We should start with one normal window. 98 // We should start with one normal window.
96 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); 99 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(),
100 browser()->host_desktop_type()));
97 101
98 // Create an incognito window. 102 // Create an incognito window.
99 chrome::NewIncognitoWindow(browser()); 103 chrome::NewIncognitoWindow(browser());
100 104
101 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); 105 ASSERT_EQ(2u, chrome::GetTotalBrowserCount());
102 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); 106 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(),
107 browser()->host_desktop_type()));
103 108
104 // Close the first window. 109 // Close the first window.
105 Profile* profile = browser()->profile(); 110 Profile* profile = browser()->profile();
111 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type();
106 content::WindowedNotificationObserver observer( 112 content::WindowedNotificationObserver observer(
107 chrome::NOTIFICATION_BROWSER_CLOSED, 113 chrome::NOTIFICATION_BROWSER_CLOSED,
108 content::NotificationService::AllSources()); 114 content::NotificationService::AllSources());
109 chrome::CloseWindow(browser()); 115 chrome::CloseWindow(browser());
110 observer.Wait(); 116 observer.Wait();
111 117
112 // There should only be the incognito window open now. 118 // There should only be the incognito window open now.
113 ASSERT_EQ(1u, chrome::GetTotalBrowserCount()); 119 ASSERT_EQ(1u, chrome::GetTotalBrowserCount());
114 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile)); 120 ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile, host_desktop_type));
115 121
116 // Run with just an URL specified, no --incognito switch. 122 // Run with just an URL specified, no --incognito switch.
117 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( 123 base::FilePath test_file_path = ui_test_utils::GetTestFilePath(
118 base::FilePath(), base::FilePath().AppendASCII("empty.html")); 124 base::FilePath(), base::FilePath().AppendASCII("empty.html"));
119 CommandLine new_command_line(GetCommandLineForRelaunch()); 125 CommandLine new_command_line(GetCommandLineForRelaunch());
120 new_command_line.AppendArgPath(test_file_path); 126 new_command_line.AppendArgPath(test_file_path);
121 content::WindowedNotificationObserver tab_observer( 127 content::WindowedNotificationObserver tab_observer(
122 chrome::NOTIFICATION_TAB_ADDED, 128 chrome::NOTIFICATION_TAB_ADDED,
123 content::NotificationService::AllSources()); 129 content::NotificationService::AllSources());
124 Relaunch(new_command_line); 130 Relaunch(new_command_line);
125 tab_observer.Wait(); 131 tab_observer.Wait();
126 132
127 // There should be one normal and one incognito window now. 133 // There should be one normal and one incognito window now.
128 ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); 134 ASSERT_EQ(2u, chrome::GetTotalBrowserCount());
129 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile)); 135 ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type));
130 } 136 }
131 137
132 #endif // !OS_MACOSX 138 #endif // !OS_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698