Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: chrome/browser/profiles/profile_manager_unittest.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add PlatformInit/Destory for all platforms Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/system_monitor/system_monitor.h"
13 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "build/build_config.h" 14 #include "build/build_config.h"
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
17 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/extensions/event_router_forwarder.h" 17 #include "chrome/browser/extensions/event_router_forwarder.h"
19 #include "chrome/browser/history/history.h" 18 #include "chrome/browser/history/history.h"
20 #include "chrome/browser/history/history_service_factory.h" 19 #include "chrome/browser/history/history_service_factory.h"
21 #include "chrome/browser/io_thread.h" 20 #include "chrome/browser/io_thread.h"
22 #include "chrome/browser/prefs/browser_prefs.h" 21 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 }; 89 };
91 90
92 ProfileManagerTest() 91 ProfileManagerTest()
93 : local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)), 92 : local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)),
94 extension_event_router_forwarder_(new extensions::EventRouterForwarder), 93 extension_event_router_forwarder_(new extensions::EventRouterForwarder),
95 ui_thread_(BrowserThread::UI, &message_loop_), 94 ui_thread_(BrowserThread::UI, &message_loop_),
96 db_thread_(BrowserThread::DB, &message_loop_), 95 db_thread_(BrowserThread::DB, &message_loop_),
97 file_thread_(BrowserThread::FILE, &message_loop_), 96 file_thread_(BrowserThread::FILE, &message_loop_),
98 io_thread_(local_state_.Get(), NULL, 97 io_thread_(local_state_.Get(), NULL,
99 extension_event_router_forwarder_) { 98 extension_event_router_forwarder_) {
100 #if defined(OS_MACOSX)
101 base::SystemMonitor::AllocateSystemIOPorts();
102 #endif
103 system_monitor_dummy_.reset(new base::SystemMonitor);
104 static_cast<TestingBrowserProcess*>(g_browser_process)->SetIOThread( 99 static_cast<TestingBrowserProcess*>(g_browser_process)->SetIOThread(
105 &io_thread_); 100 &io_thread_);
106 } 101 }
107 102
108 virtual void SetUp() { 103 virtual void SetUp() {
109 // Create a new temporary directory, and store the path 104 // Create a new temporary directory, and store the path
110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 105 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
111 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( 106 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager(
112 new testing::ProfileManager(temp_dir_.path())); 107 new testing::ProfileManager(temp_dir_.path()));
113 108
(...skipping 21 matching lines...) Expand all
135 ScopedTestingLocalState local_state_; 130 ScopedTestingLocalState local_state_;
136 scoped_refptr<extensions::EventRouterForwarder> 131 scoped_refptr<extensions::EventRouterForwarder>
137 extension_event_router_forwarder_; 132 extension_event_router_forwarder_;
138 133
139 MessageLoopForUI message_loop_; 134 MessageLoopForUI message_loop_;
140 content::TestBrowserThread ui_thread_; 135 content::TestBrowserThread ui_thread_;
141 content::TestBrowserThread db_thread_; 136 content::TestBrowserThread db_thread_;
142 content::TestBrowserThread file_thread_; 137 content::TestBrowserThread file_thread_;
143 // IOThread is necessary for the creation of some services below. 138 // IOThread is necessary for the creation of some services below.
144 IOThread io_thread_; 139 IOThread io_thread_;
145
146 scoped_ptr<base::SystemMonitor> system_monitor_dummy_;
147 }; 140 };
148 141
149 TEST_F(ProfileManagerTest, GetProfile) { 142 TEST_F(ProfileManagerTest, GetProfile) {
150 FilePath dest_path = temp_dir_.path(); 143 FilePath dest_path = temp_dir_.path();
151 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); 144 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile"));
152 145
153 ProfileManager* profile_manager = g_browser_process->profile_manager(); 146 ProfileManager* profile_manager = g_browser_process->profile_manager();
154 147
155 // Successfully create a profile. 148 // Successfully create a profile.
156 Profile* profile = profile_manager->GetProfile(dest_path); 149 Profile* profile = profile_manager->GetProfile(dest_path);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 browser2b.reset(); 552 browser2b.reset();
560 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 553 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
561 ASSERT_EQ(1U, last_opened_profiles.size()); 554 ASSERT_EQ(1U, last_opened_profiles.size());
562 EXPECT_EQ(profile1, last_opened_profiles[0]); 555 EXPECT_EQ(profile1, last_opened_profiles[0]);
563 556
564 browser1.reset(); 557 browser1.reset();
565 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 558 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
566 ASSERT_EQ(0U, last_opened_profiles.size()); 559 ASSERT_EQ(0U, last_opened_profiles.size());
567 } 560 }
568 #endif // !defined(OS_ANDROID) 561 #endif // !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698