| 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/profile.h" | 10 #include "chrome/browser/profile.h" |
| 10 #include "chrome/test/testing_profile.h" | 11 #include "chrome/test/testing_profile.h" |
| 11 | 12 |
| 12 // Base class which contains a valid Browser*. Lots of boilerplate to | 13 // Base class which contains a valid Browser*. Lots of boilerplate to |
| 13 // recycle between unit test classes. | 14 // recycle between unit test classes. |
| 14 // | 15 // |
| 15 // TODO(jrg): move up a level (chrome/browser/cocoa --> | 16 // TODO(jrg): move up a level (chrome/browser/cocoa --> |
| 16 // chrome/browser), and use in non-Mac unit tests such as | 17 // chrome/browser), and use in non-Mac unit tests such as |
| 17 // back_forward_menu_model_unittest.cc, | 18 // back_forward_menu_model_unittest.cc, |
| 18 // navigation_controller_unittest.cc, .. | 19 // navigation_controller_unittest.cc, .. |
| 19 class BrowserTestHelper { | 20 class BrowserTestHelper { |
| 20 public: | 21 public: |
| 21 BrowserTestHelper() { | 22 BrowserTestHelper() |
| 23 : ui_thread_(ChromeThread::UI, &message_loop_), |
| 24 file_thread_(ChromeThread::FILE, &message_loop_) { |
| 22 profile_.reset(new TestingProfile()); | 25 profile_.reset(new TestingProfile()); |
| 23 profile_->CreateBookmarkModel(true); | 26 profile_->CreateBookmarkModel(true); |
| 24 profile_->BlockUntilBookmarkModelLoaded(); | 27 profile_->BlockUntilBookmarkModelLoaded(); |
| 25 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); | 28 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); |
| 26 } | 29 } |
| 27 | 30 |
| 28 TestingProfile* profile() const { return profile_.get(); } | 31 TestingProfile* profile() const { return profile_.get(); } |
| 29 Browser* browser() const { return browser_.get(); } | 32 Browser* browser() const { return browser_.get(); } |
| 30 | 33 |
| 31 private: | 34 private: |
| 32 scoped_ptr<TestingProfile> profile_; | 35 scoped_ptr<TestingProfile> profile_; |
| 33 scoped_ptr<Browser> browser_; | 36 scoped_ptr<Browser> browser_; |
| 34 MessageLoopForUI message_loop_; | 37 MessageLoopForUI message_loop_; |
| 38 ChromeThread ui_thread_; |
| 39 ChromeThread file_thread_; |
| 35 }; | 40 }; |
| 36 | 41 |
| 37 #endif // CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ | 42 #endif // CHROME_BROWSER_COCOA_BROWSER_TEST_HELPER_H_ |
| OLD | NEW |