diff options
Diffstat (limited to 'chrome/browser/cocoa/browser_test_helper.h')
-rw-r--r-- | chrome/browser/cocoa/browser_test_helper.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/browser_test_helper.h b/chrome/browser/cocoa/browser_test_helper.h new file mode 100644 index 0000000..6427547 --- /dev/null +++ b/chrome/browser/cocoa/browser_test_helper.h @@ -0,0 +1,38 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/browser.h" +#include "chrome/browser/profile.h" +#include "chrome/test/testing_profile.h" + +// Base class which contains a valid Browser*. Lots of boilerplate to +// recycle between unit test classes. +// +// TODO(jrg): move up a level (chrome/browser/cocoa --> +// chrome/browser), and use in non-Mac unit tests such as +// back_forward_menu_model_unittest.cc, +// navigation_controller_unittest.cc, .. +class BrowserTestHelper { + public: + BrowserTestHelper() { + TestingProfile *testing_profile = new TestingProfile(); + testing_profile->CreateBookmarkModel(true); + testing_profile->BlockUntilBookmarkModelLoaded(); + profile_ = testing_profile; + browser_ = new Browser(Browser::TYPE_NORMAL, profile_); + } + + ~BrowserTestHelper() { + delete browser_; + delete profile_; + } + + Browser* GetBrowser() { return browser_; } + Profile* GetProfile() { return profile_; } + + private: + Browser* browser_; + Profile* profile_; + MessageLoopForUI message_loop_; +}; |