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" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #include "chrome/test/base/scoped_testing_local_state.h" | 32 #include "chrome/test/base/scoped_testing_local_state.h" |
33 #include "chrome/test/base/test_browser_window.h" | 33 #include "chrome/test/base/test_browser_window.h" |
34 #include "chrome/test/base/testing_browser_process.h" | 34 #include "chrome/test/base/testing_browser_process.h" |
35 #include "chrome/test/base/testing_profile.h" | 35 #include "chrome/test/base/testing_profile.h" |
36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "content/public/test/test_browser_thread.h" | 37 #include "content/public/test/test_browser_thread.h" |
38 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
40 | 40 |
41 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
42 #include "chrome/browser/chromeos/cros/cros_library.h" | |
43 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 42 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
44 #include "chrome/browser/chromeos/login/user_manager.h" | 43 #include "chrome/browser/chromeos/login/user_manager.h" |
45 #include "chrome/browser/chromeos/settings/cros_settings.h" | 44 #include "chrome/browser/chromeos/settings/cros_settings.h" |
46 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 45 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
47 #include "chromeos/chromeos_switches.h" | 46 #include "chromeos/chromeos_switches.h" |
48 #endif | 47 #endif |
49 | 48 |
50 using content::BrowserThread; | 49 using content::BrowserThread; |
51 | 50 |
52 namespace { | 51 namespace { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 public: | 92 public: |
94 MOCK_METHOD2(OnProfileCreated, | 93 MOCK_METHOD2(OnProfileCreated, |
95 void(Profile* profile, Profile::CreateStatus status)); | 94 void(Profile* profile, Profile::CreateStatus status)); |
96 }; | 95 }; |
97 | 96 |
98 ProfileManagerTest() | 97 ProfileManagerTest() |
99 : local_state_(TestingBrowserProcess::GetGlobal()), | 98 : local_state_(TestingBrowserProcess::GetGlobal()), |
100 extension_event_router_forwarder_(new extensions::EventRouterForwarder), | 99 extension_event_router_forwarder_(new extensions::EventRouterForwarder), |
101 ui_thread_(BrowserThread::UI, &message_loop_), | 100 ui_thread_(BrowserThread::UI, &message_loop_), |
102 db_thread_(BrowserThread::DB, &message_loop_), | 101 db_thread_(BrowserThread::DB, &message_loop_), |
103 file_thread_(BrowserThread::FILE, &message_loop_), | 102 file_thread_(BrowserThread::FILE, &message_loop_) { |
104 io_thread_(local_state_.Get(), g_browser_process->policy_service(), | |
105 NULL, extension_event_router_forwarder_) { | |
106 TestingBrowserProcess::GetGlobal()->SetIOThread(&io_thread_); | |
107 } | 103 } |
108 | 104 |
109 virtual void SetUp() { | 105 virtual void SetUp() { |
110 // Create a new temporary directory, and store the path | 106 // Create a new temporary directory, and store the path |
111 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 107 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
112 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 108 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
113 new testing::ProfileManager(temp_dir_.path())); | 109 new testing::ProfileManager(temp_dir_.path())); |
114 | 110 |
115 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
116 CommandLine* cl = CommandLine::ForCurrentProcess(); | 112 CommandLine* cl = CommandLine::ForCurrentProcess(); |
117 cl->AppendSwitch(switches::kTestType); | 113 cl->AppendSwitch(switches::kTestType); |
118 #endif | 114 #endif |
119 } | 115 } |
120 | 116 |
121 virtual void TearDown() { | 117 virtual void TearDown() { |
122 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); | 118 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
123 message_loop_.RunUntilIdle(); | 119 message_loop_.RunUntilIdle(); |
124 } | 120 } |
125 | 121 |
126 #if defined(OS_CHROMEOS) | 122 #if defined(OS_CHROMEOS) |
127 // Do not change order of stub_cros_enabler_, which needs to be constructed | |
128 // before io_thread_ which requires CrosLibrary to be initialized to construct | |
129 // its data member pref_proxy_config_tracker_ on ChromeOS. | |
130 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; | |
131 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 123 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
132 chromeos::ScopedTestCrosSettings test_cros_settings_; | 124 chromeos::ScopedTestCrosSettings test_cros_settings_; |
133 #endif | 125 #endif |
134 | 126 |
135 // The path to temporary directory used to contain the test operations. | 127 // The path to temporary directory used to contain the test operations. |
136 base::ScopedTempDir temp_dir_; | 128 base::ScopedTempDir temp_dir_; |
137 ScopedTestingLocalState local_state_; | 129 ScopedTestingLocalState local_state_; |
138 scoped_refptr<extensions::EventRouterForwarder> | 130 scoped_refptr<extensions::EventRouterForwarder> |
139 extension_event_router_forwarder_; | 131 extension_event_router_forwarder_; |
140 | 132 |
141 MessageLoopForUI message_loop_; | 133 MessageLoopForUI message_loop_; |
142 content::TestBrowserThread ui_thread_; | 134 content::TestBrowserThread ui_thread_; |
143 content::TestBrowserThread db_thread_; | 135 content::TestBrowserThread db_thread_; |
144 content::TestBrowserThread file_thread_; | 136 content::TestBrowserThread file_thread_; |
145 // IOThread is necessary for the creation of some services below. | |
146 IOThread io_thread_; | |
rpetterson
2013/05/28 17:08:38
I assume you've tested that these test still pass?
| |
147 | 137 |
148 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
149 chromeos::ScopedTestUserManager test_user_manager_; | 139 chromeos::ScopedTestUserManager test_user_manager_; |
150 #endif | 140 #endif |
151 }; | 141 }; |
152 | 142 |
153 TEST_F(ProfileManagerTest, GetProfile) { | 143 TEST_F(ProfileManagerTest, GetProfile) { |
154 base::FilePath dest_path = temp_dir_.path(); | 144 base::FilePath dest_path = temp_dir_.path(); |
155 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); | 145 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); |
156 | 146 |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 browser2b.reset(); | 601 browser2b.reset(); |
612 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 602 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
613 ASSERT_EQ(1U, last_opened_profiles.size()); | 603 ASSERT_EQ(1U, last_opened_profiles.size()); |
614 EXPECT_EQ(profile1, last_opened_profiles[0]); | 604 EXPECT_EQ(profile1, last_opened_profiles[0]); |
615 | 605 |
616 browser1.reset(); | 606 browser1.reset(); |
617 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 607 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
618 ASSERT_EQ(0U, last_opened_profiles.size()); | 608 ASSERT_EQ(0U, last_opened_profiles.size()); |
619 } | 609 } |
620 #endif // !defined(OS_ANDROID) | 610 #endif // !defined(OS_ANDROID) |
OLD | NEW |