| OLD | NEW |
| 1 // Copyright (c) 2011 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_PROFILE_TEST_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "chrome/browser/ui/browser.h" | |
| 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | |
| 13 #include "chrome/test/base/testing_profile.h" | |
| 14 #include "chrome/test/base/testing_profile_manager.h" | 10 #include "chrome/test/base/testing_profile_manager.h" |
| 15 #include "content/public/test/test_browser_thread.h" | 11 |
| 12 namespace content { |
| 13 class TestBrowserThreadBundle; |
| 14 } |
| 15 |
| 16 class Browser; |
| 17 class TestingProfile; |
| 16 | 18 |
| 17 // Base class which contains a valid Browser*. Lots of boilerplate to | 19 // Base class which contains a valid Browser*. Lots of boilerplate to |
| 18 // recycle between unit test classes. | 20 // recycle between unit test classes. |
| 19 // | 21 // |
| 20 // This class creates fake UI, file, and IO threads because many objects that | 22 // This class creates fake UI, file, and IO threads because many objects that |
| 21 // are attached to the TestingProfile (and other objects) have traits that limit | 23 // are attached to the TestingProfile (and other objects) have traits that limit |
| 22 // their destruction to certain threads. For example, the net::URLRequestContext | 24 // their destruction to certain threads. For example, the net::URLRequestContext |
| 23 // can only be deleted on the IO thread; without this fake IO thread, the object | 25 // can only be deleted on the IO thread; without this fake IO thread, the object |
| 24 // would never be deleted and would report as a leak under Valgrind. Note that | 26 // would never be deleted and would report as a leak under Valgrind. Note that |
| 25 // these are fake threads and they all share the same MessageLoop. | 27 // these are fake threads and they all share the same MessageLoop. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 // Closes the window for this browser. This will automatically be called as | 52 // Closes the window for this browser. This will automatically be called as |
| 51 // part of TearDown() if it's not been done already. | 53 // part of TearDown() if it's not been done already. |
| 52 void CloseBrowserWindow(); | 54 void CloseBrowserWindow(); |
| 53 | 55 |
| 54 protected: | 56 protected: |
| 55 // Overridden by test subclasses to create their own browser, e.g. with a | 57 // Overridden by test subclasses to create their own browser, e.g. with a |
| 56 // test window. | 58 // test window. |
| 57 virtual Browser* CreateBrowser(); | 59 virtual Browser* CreateBrowser(); |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 base::MessageLoopForUI message_loop_; | |
| 61 content::TestBrowserThread ui_thread_; | |
| 62 | |
| 63 TestingProfileManager profile_manager_; | 62 TestingProfileManager profile_manager_; |
| 64 TestingProfile* profile_; // Weak; owned by profile_manager_. | 63 TestingProfile* profile_; // Weak; owned by profile_manager_. |
| 65 scoped_ptr<Browser> browser_; | 64 scoped_ptr<Browser> browser_; |
| 66 | 65 |
| 67 scoped_ptr<content::TestBrowserThread> file_user_blocking_thread_; | 66 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; |
| 68 scoped_ptr<content::TestBrowserThread> file_thread_; | |
| 69 scoped_ptr<content::TestBrowserThread> io_thread_; | |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 #endif // CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_ | 69 #endif // CHROME_BROWSER_UI_COCOA_PROFILE_TEST_H_ |
| OLD | NEW |