OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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_UI_COCOA_BROWSER_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_TEST_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/test/testing_profile.h" | 11 #include "chrome/test/testing_profile.h" |
12 | 12 |
13 // Base class which contains a valid Browser*. Lots of boilerplate to | 13 // Base class which contains a valid Browser*. Lots of boilerplate to |
14 // recycle between unit test classes. | 14 // recycle between unit test classes. |
15 // | 15 // |
16 // This class creates fake UI, file, and IO threads because many objects that | 16 // This class creates fake UI, file, and IO threads because many objects that |
17 // are attached to the TestingProfile (and other objects) have traits that limit | 17 // are attached to the TestingProfile (and other objects) have traits that limit |
18 // their destruction to certain threads. For example, the URLRequestContext can | 18 // their destruction to certain threads. For example, the net::URLRequestContext |
19 // only be deleted on the IO thread; without this fake IO thread, the object | 19 // can only be deleted on the IO thread; without this fake IO thread, the object |
20 // would never be deleted and would report as a leak under Valgrind. Note that | 20 // would never be deleted and would report as a leak under Valgrind. Note that |
21 // these are fake threads and they all share the same MessageLoop. | 21 // these are fake threads and they all share the same MessageLoop. |
22 // | 22 // |
23 // TODO(jrg): move up a level (chrome/browser/ui/cocoa --> | 23 // TODO(jrg): move up a level (chrome/browser/ui/cocoa --> |
24 // chrome/browser), and use in non-Mac unit tests such as | 24 // chrome/browser), and use in non-Mac unit tests such as |
25 // back_forward_menu_model_unittest.cc, | 25 // back_forward_menu_model_unittest.cc, |
26 // navigation_controller_unittest.cc, .. | 26 // navigation_controller_unittest.cc, .. |
27 class BrowserTestHelper { | 27 class BrowserTestHelper { |
28 public: | 28 public: |
29 BrowserTestHelper() | 29 BrowserTestHelper() |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 private: | 82 private: |
83 scoped_ptr<TestingProfile> profile_; | 83 scoped_ptr<TestingProfile> profile_; |
84 scoped_ptr<Browser> browser_; | 84 scoped_ptr<Browser> browser_; |
85 MessageLoopForUI message_loop_; | 85 MessageLoopForUI message_loop_; |
86 BrowserThread ui_thread_; | 86 BrowserThread ui_thread_; |
87 scoped_ptr<BrowserThread> file_thread_; | 87 scoped_ptr<BrowserThread> file_thread_; |
88 scoped_ptr<BrowserThread> io_thread_; | 88 scoped_ptr<BrowserThread> io_thread_; |
89 }; | 89 }; |
90 | 90 |
91 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_TEST_HELPER_H_ | 91 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_TEST_HELPER_H_ |
OLD | NEW |