summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/browser_test_helper.h
blob: 19ce3b5318bf06d4d5a072e490cab93f5245b111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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* browser() { return browser_; }
  Profile* profile() { return profile_; }

 private:
  Browser* browser_;
  Profile* profile_;
  MessageLoopForUI message_loop_;
};