| 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 "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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Relaunch(GetCommandLineForRelaunch()); | 43 Relaunch(GetCommandLineForRelaunch()); |
| 44 observer.WaitForSingleNewBrowser(); | 44 observer.WaitForSingleNewBrowser(); |
| 45 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); | 45 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 46 } | 46 } |
| 47 | 47 |
| 48 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { | 48 IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { |
| 49 FilePath test_file_path = ui_test_utils::GetTestFilePath( | 49 FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| 50 FilePath(), FilePath().AppendASCII("empty.html")); | 50 FilePath(), FilePath().AppendASCII("empty.html")); |
| 51 CommandLine new_command_line(GetCommandLineForRelaunch()); | 51 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 52 new_command_line.AppendArgPath(test_file_path); | 52 new_command_line.AppendArgPath(test_file_path); |
| 53 ui_test_utils::WindowedNotificationObserver observer( | 53 content::WindowedNotificationObserver observer( |
| 54 chrome::NOTIFICATION_TAB_ADDED, | 54 chrome::NOTIFICATION_TAB_ADDED, |
| 55 content::NotificationService::AllSources()); | 55 content::NotificationService::AllSources()); |
| 56 Relaunch(new_command_line); | 56 Relaunch(new_command_line); |
| 57 observer.Wait(); | 57 observer.Wait(); |
| 58 | 58 |
| 59 GURL url = net::FilePathToFileURL(test_file_path); | 59 GURL url = net::FilePathToFileURL(test_file_path); |
| 60 content::WebContents* tab = chrome::GetActiveWebContents(browser()); | 60 content::WebContents* tab = chrome::GetActiveWebContents(browser()); |
| 61 ASSERT_EQ(url, tab->GetController().GetActiveEntry()->GetVirtualURL()); | 61 ASSERT_EQ(url, tab->GetController().GetActiveEntry()->GetVirtualURL()); |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile())); | 96 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile())); |
| 97 | 97 |
| 98 // Create an incognito window. | 98 // Create an incognito window. |
| 99 chrome::NewIncognitoWindow(browser()); | 99 chrome::NewIncognitoWindow(browser()); |
| 100 | 100 |
| 101 ASSERT_EQ(2u, BrowserList::size()); | 101 ASSERT_EQ(2u, BrowserList::size()); |
| 102 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile())); | 102 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile())); |
| 103 | 103 |
| 104 // Close the first window. | 104 // Close the first window. |
| 105 Profile* profile = browser()->profile(); | 105 Profile* profile = browser()->profile(); |
| 106 ui_test_utils::WindowedNotificationObserver observer( | 106 content::WindowedNotificationObserver observer( |
| 107 chrome::NOTIFICATION_BROWSER_CLOSED, | 107 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 108 content::NotificationService::AllSources()); | 108 content::NotificationService::AllSources()); |
| 109 chrome::CloseWindow(browser()); | 109 chrome::CloseWindow(browser()); |
| 110 observer.Wait(); | 110 observer.Wait(); |
| 111 | 111 |
| 112 // There should only be the incognito window open now. | 112 // There should only be the incognito window open now. |
| 113 ASSERT_EQ(1u, BrowserList::size()); | 113 ASSERT_EQ(1u, BrowserList::size()); |
| 114 ASSERT_EQ(0u, browser::GetTabbedBrowserCount(profile)); | 114 ASSERT_EQ(0u, browser::GetTabbedBrowserCount(profile)); |
| 115 | 115 |
| 116 // Run with just an URL specified, no --incognito switch. | 116 // Run with just an URL specified, no --incognito switch. |
| 117 FilePath test_file_path = ui_test_utils::GetTestFilePath( | 117 FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| 118 FilePath(), FilePath().AppendASCII("empty.html")); | 118 FilePath(), FilePath().AppendASCII("empty.html")); |
| 119 CommandLine new_command_line(GetCommandLineForRelaunch()); | 119 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 120 new_command_line.AppendArgPath(test_file_path); | 120 new_command_line.AppendArgPath(test_file_path); |
| 121 ui_test_utils::WindowedNotificationObserver tab_observer( | 121 content::WindowedNotificationObserver tab_observer( |
| 122 chrome::NOTIFICATION_TAB_ADDED, | 122 chrome::NOTIFICATION_TAB_ADDED, |
| 123 content::NotificationService::AllSources()); | 123 content::NotificationService::AllSources()); |
| 124 Relaunch(new_command_line); | 124 Relaunch(new_command_line); |
| 125 tab_observer.Wait(); | 125 tab_observer.Wait(); |
| 126 | 126 |
| 127 // There should be one normal and one incognito window now. | 127 // There should be one normal and one incognito window now. |
| 128 ASSERT_EQ(2u, BrowserList::size()); | 128 ASSERT_EQ(2u, BrowserList::size()); |
| 129 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(profile)); | 129 ASSERT_EQ(1u, browser::GetTabbedBrowserCount(profile)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 #endif // !OS_MACOSX | 132 #endif // !OS_MACOSX |
| OLD | NEW |