[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / cocoa_profile_test.h
blob93d681be37286f6205c066178abb77d4f589b87e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_
6 #define CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_
8 #include "base/memory/scoped_ptr.h"
9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
10 #include "chrome/test/base/testing_profile_manager.h"
12 namespace content {
13 class TestBrowserThreadBundle;
16 class Browser;
17 class TestingProfile;
19 // Base class which contains a valid Browser*. Lots of boilerplate to
20 // recycle between unit test classes.
22 // This class creates fake UI, file, and IO threads because many objects that
23 // are attached to the TestingProfile (and other objects) have traits that limit
24 // their destruction to certain threads. For example, the net::URLRequestContext
25 // can only be deleted on the IO thread; without this fake IO thread, the object
26 // would never be deleted and would report as a leak under Valgrind. Note that
27 // these are fake threads and they all share the same MessageLoop.
29 // TODO(jrg): move up a level (chrome/browser/ui/cocoa -->
30 // chrome/browser), and use in non-Mac unit tests such as
31 // back_forward_menu_model_unittest.cc,
32 // navigation_controller_unittest.cc, ..
33 class CocoaProfileTest : public CocoaTest {
34 public:
35 CocoaProfileTest();
36 virtual ~CocoaProfileTest();
38 // This constructs a a Browser and a TestingProfile. It is guaranteed to
39 // succeed, else it will ASSERT and cause the test to fail. Subclasses that
40 // do work in SetUp should ASSERT that either browser() or profile() are
41 // non-NULL before proceeding after the call to super (this).
42 virtual void SetUp() OVERRIDE;
44 virtual void TearDown() OVERRIDE;
46 TestingProfileManager* testing_profile_manager() {
47 return &profile_manager_;
49 TestingProfile* profile() { return profile_; }
50 Browser* browser() { return browser_.get(); }
52 // Closes the window for this browser. This will automatically be called as
53 // part of TearDown() if it's not been done already.
54 void CloseBrowserWindow();
56 protected:
57 // Overridden by test subclasses to create their own browser, e.g. with a
58 // test window.
59 virtual Browser* CreateBrowser();
61 private:
62 TestingProfileManager profile_manager_;
63 TestingProfile* profile_; // Weak; owned by profile_manager_.
64 scoped_ptr<Browser> browser_;
66 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
69 #endif // CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_