Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/system_monitor/system_monitor.h" | 12 #include "base/power_monitor/power_monitor.h" |
|
vandebo (ex-Chrome)
2013/03/19 23:36:04
Does this need a dummy system monitor, or a dummy
Hongbo Min
2013/03/20 13:01:50
I found neither. I really doubt the purpose of the
| |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/extensions/event_router_forwarder.h" | 18 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 19 #include "chrome/browser/history/history_service.h" | 19 #include "chrome/browser/history/history_service.h" |
| 20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 21 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
| 22 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 ProfileManagerTest() | 93 ProfileManagerTest() |
| 94 : local_state_(TestingBrowserProcess::GetGlobal()), | 94 : local_state_(TestingBrowserProcess::GetGlobal()), |
| 95 extension_event_router_forwarder_(new extensions::EventRouterForwarder), | 95 extension_event_router_forwarder_(new extensions::EventRouterForwarder), |
| 96 ui_thread_(BrowserThread::UI, &message_loop_), | 96 ui_thread_(BrowserThread::UI, &message_loop_), |
| 97 db_thread_(BrowserThread::DB, &message_loop_), | 97 db_thread_(BrowserThread::DB, &message_loop_), |
| 98 file_thread_(BrowserThread::FILE, &message_loop_), | 98 file_thread_(BrowserThread::FILE, &message_loop_), |
| 99 io_thread_(local_state_.Get(), g_browser_process->policy_service(), | 99 io_thread_(local_state_.Get(), g_browser_process->policy_service(), |
| 100 NULL, extension_event_router_forwarder_) { | 100 NULL, extension_event_router_forwarder_) { |
| 101 #if defined(OS_MACOSX) | |
| 102 base::SystemMonitor::AllocateSystemIOPorts(); | |
| 103 #endif | |
| 104 system_monitor_dummy_.reset(new base::SystemMonitor); | |
| 105 TestingBrowserProcess::GetGlobal()->SetIOThread(&io_thread_); | 101 TestingBrowserProcess::GetGlobal()->SetIOThread(&io_thread_); |
| 106 } | 102 } |
| 107 | 103 |
| 108 virtual void SetUp() { | 104 virtual void SetUp() { |
| 109 // Create a new temporary directory, and store the path | 105 // Create a new temporary directory, and store the path |
| 110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 106 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 111 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 107 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
| 112 new testing::ProfileManager(temp_dir_.path())); | 108 new testing::ProfileManager(temp_dir_.path())); |
| 113 | 109 |
| 114 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 134 ScopedTestingLocalState local_state_; | 130 ScopedTestingLocalState local_state_; |
| 135 scoped_refptr<extensions::EventRouterForwarder> | 131 scoped_refptr<extensions::EventRouterForwarder> |
| 136 extension_event_router_forwarder_; | 132 extension_event_router_forwarder_; |
| 137 | 133 |
| 138 MessageLoopForUI message_loop_; | 134 MessageLoopForUI message_loop_; |
| 139 content::TestBrowserThread ui_thread_; | 135 content::TestBrowserThread ui_thread_; |
| 140 content::TestBrowserThread db_thread_; | 136 content::TestBrowserThread db_thread_; |
| 141 content::TestBrowserThread file_thread_; | 137 content::TestBrowserThread file_thread_; |
| 142 // IOThread is necessary for the creation of some services below. | 138 // IOThread is necessary for the creation of some services below. |
| 143 IOThread io_thread_; | 139 IOThread io_thread_; |
| 144 | |
| 145 scoped_ptr<base::SystemMonitor> system_monitor_dummy_; | |
| 146 }; | 140 }; |
| 147 | 141 |
| 148 TEST_F(ProfileManagerTest, GetProfile) { | 142 TEST_F(ProfileManagerTest, GetProfile) { |
| 149 base::FilePath dest_path = temp_dir_.path(); | 143 base::FilePath dest_path = temp_dir_.path(); |
| 150 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); | 144 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); |
| 151 | 145 |
| 152 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 146 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 153 | 147 |
| 154 // Successfully create a profile. | 148 // Successfully create a profile. |
| 155 Profile* profile = profile_manager->GetProfile(dest_path); | 149 Profile* profile = profile_manager->GetProfile(dest_path); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 browser2b.reset(); | 596 browser2b.reset(); |
| 603 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 597 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
| 604 ASSERT_EQ(1U, last_opened_profiles.size()); | 598 ASSERT_EQ(1U, last_opened_profiles.size()); |
| 605 EXPECT_EQ(profile1, last_opened_profiles[0]); | 599 EXPECT_EQ(profile1, last_opened_profiles[0]); |
| 606 | 600 |
| 607 browser1.reset(); | 601 browser1.reset(); |
| 608 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 602 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
| 609 ASSERT_EQ(0U, last_opened_profiles.size()); | 603 ASSERT_EQ(0U, last_opened_profiles.size()); |
| 610 } | 604 } |
| 611 #endif // !defined(OS_ANDROID) | 605 #endif // !defined(OS_ANDROID) |
| OLD | NEW |