OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ |
7 | 7 |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // window off of browser_. pkasting indicates that other | 30 // window off of browser_. pkasting indicates that other |
31 // platforms use a stub |BrowserWindow| and thus don't need to do | 31 // platforms use a stub |BrowserWindow| and thus don't need to do |
32 // this. | 32 // this. |
33 // http://crbug.com/39725 | 33 // http://crbug.com/39725 |
34 profile_->CreateAutocompleteClassifier(); | 34 profile_->CreateAutocompleteClassifier(); |
35 profile_->CreateTemplateURLModel(); | 35 profile_->CreateTemplateURLModel(); |
36 | 36 |
37 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); | 37 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); |
38 } | 38 } |
39 | 39 |
40 ~BrowserTestHelper() { | 40 virtual ~BrowserTestHelper() { |
41 // Delete the testing profile on the UI thread. But first release the | 41 // Delete the testing profile on the UI thread. But first release the |
42 // browser, since it may trigger accesses to the profile upon destruction. | 42 // browser, since it may trigger accesses to the profile upon destruction. |
43 browser_.reset(NULL); | 43 browser_.reset(NULL); |
44 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); | 44 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); |
45 message_loop_.RunAllPending(); | 45 message_loop_.RunAllPending(); |
46 } | 46 } |
47 | 47 |
48 TestingProfile* profile() const { return profile_.get(); } | 48 virtual TestingProfile* profile() const { return profile_.get(); } |
49 Browser* browser() const { return browser_.get(); } | 49 Browser* browser() const { return browser_.get(); } |
50 | 50 |
51 // Creates the browser window. To close this window call |CloseBrowserWindow|. | 51 // Creates the browser window. To close this window call |CloseBrowserWindow|. |
52 // Do NOT call close directly on the window. | 52 // Do NOT call close directly on the window. |
53 BrowserWindow* CreateBrowserWindow() { | 53 BrowserWindow* CreateBrowserWindow() { |
54 browser_->CreateBrowserWindow(); | 54 browser_->CreateBrowserWindow(); |
55 return browser_->window(); | 55 return browser_->window(); |
56 } | 56 } |
57 | 57 |
58 // Closes the window for this browser. | 58 // Closes the window for this browser. |
59 void CloseBrowserWindow() { | 59 void CloseBrowserWindow() { |
60 // Check to make sure a window was actually created. | 60 // Check to make sure a window was actually created. |
61 DCHECK(browser_->window()); | 61 DCHECK(browser_->window()); |
62 browser_->CloseAllTabs(); | 62 browser_->CloseAllTabs(); |
63 browser_->CloseWindow(); | 63 browser_->CloseWindow(); |
64 browser_.release(); | 64 browser_.release(); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 scoped_ptr<TestingProfile> profile_; | 68 scoped_ptr<TestingProfile> profile_; |
69 scoped_ptr<Browser> browser_; | 69 scoped_ptr<Browser> browser_; |
70 MessageLoopForUI message_loop_; | 70 MessageLoopForUI message_loop_; |
71 ChromeThread ui_thread_; | 71 ChromeThread ui_thread_; |
72 ChromeThread file_thread_; | 72 ChromeThread file_thread_; |
73 }; | 73 }; |
74 | 74 |
75 #endif // CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ | 75 #endif // CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ |
OLD | NEW |