| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 void InProcessBrowserTest::TearDown() { | 182 void InProcessBrowserTest::TearDown() { |
| 183 DCHECK(!g_browser_process); | 183 DCHECK(!g_browser_process); |
| 184 BrowserTestBase::TearDown(); | 184 BrowserTestBase::TearDown(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void InProcessBrowserTest::AddTabAtIndexToBrowser( | 187 void InProcessBrowserTest::AddTabAtIndexToBrowser( |
| 188 Browser* browser, | 188 Browser* browser, |
| 189 int index, | 189 int index, |
| 190 const GURL& url, | 190 const GURL& url, |
| 191 PageTransition::Type transition) { | 191 content::PageTransition transition) { |
| 192 browser::NavigateParams params(browser, url, transition); | 192 browser::NavigateParams params(browser, url, transition); |
| 193 params.tabstrip_index = index; | 193 params.tabstrip_index = index; |
| 194 params.disposition = NEW_FOREGROUND_TAB; | 194 params.disposition = NEW_FOREGROUND_TAB; |
| 195 browser::Navigate(¶ms); | 195 browser::Navigate(¶ms); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void InProcessBrowserTest::AddTabAtIndex( | 198 void InProcessBrowserTest::AddTabAtIndex( |
| 199 int index, | 199 int index, |
| 200 const GURL& url, | 200 const GURL& url, |
| 201 PageTransition::Type transition) { | 201 content::PageTransition transition) { |
| 202 AddTabAtIndexToBrowser(browser(), index, url, transition); | 202 AddTabAtIndexToBrowser(browser(), index, url, transition); |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool InProcessBrowserTest::SetUpUserDataDirectory() { | 205 bool InProcessBrowserTest::SetUpUserDataDirectory() { |
| 206 return true; | 206 return true; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Creates a browser with a single tab (about:blank), waits for the tab to | 209 // Creates a browser with a single tab (about:blank), waits for the tab to |
| 210 // finish loading and shows the browser. | 210 // finish loading and shows the browser. |
| 211 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { | 211 Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 226 Browser* browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); | 226 Browser* browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); |
| 227 AddBlankTabAndShow(browser); | 227 AddBlankTabAndShow(browser); |
| 228 return browser; | 228 return browser; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { | 231 void InProcessBrowserTest::AddBlankTabAndShow(Browser* browser) { |
| 232 ui_test_utils::WindowedNotificationObserver observer( | 232 ui_test_utils::WindowedNotificationObserver observer( |
| 233 content::NOTIFICATION_LOAD_STOP, | 233 content::NOTIFICATION_LOAD_STOP, |
| 234 NotificationService::AllSources()); | 234 NotificationService::AllSources()); |
| 235 browser->AddSelectedTabWithURL( | 235 browser->AddSelectedTabWithURL( |
| 236 GURL(chrome::kAboutBlankURL), PageTransition::START_PAGE); | 236 GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_START_PAGE); |
| 237 observer.Wait(); | 237 observer.Wait(); |
| 238 | 238 |
| 239 browser->window()->Show(); | 239 browser->window()->Show(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 #if defined(OS_POSIX) | 242 #if defined(OS_POSIX) |
| 243 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make | 243 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make |
| 244 // debugging easier) and also exit with a known error code (so that the test | 244 // debugging easier) and also exit with a known error code (so that the test |
| 245 // framework considers this a failure -- http://crbug.com/57578). | 245 // framework considers this a failure -- http://crbug.com/57578). |
| 246 static void DumpStackTraceSignalHandler(int signal) { | 246 static void DumpStackTraceSignalHandler(int signal) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 return; | 292 return; |
| 293 | 293 |
| 294 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 294 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
| 295 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 295 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
| 296 // shut down properly. | 296 // shut down properly. |
| 297 MessageLoopForUI::current()->PostTask( | 297 MessageLoopForUI::current()->PostTask( |
| 298 FROM_HERE, | 298 FROM_HERE, |
| 299 NewRunnableFunction(&BrowserList::AttemptExit)); | 299 NewRunnableFunction(&BrowserList::AttemptExit)); |
| 300 ui_test_utils::RunMessageLoop(); | 300 ui_test_utils::RunMessageLoop(); |
| 301 } | 301 } |
| OLD | NEW |