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 22 matching lines...) Expand all Loading... |
33 #include "chrome/test/base/scoped_testing_local_state.h" | 33 #include "chrome/test/base/scoped_testing_local_state.h" |
34 #include "chrome/test/base/test_browser_window.h" | 34 #include "chrome/test/base/test_browser_window.h" |
35 #include "chrome/test/base/testing_browser_process.h" | 35 #include "chrome/test/base/testing_browser_process.h" |
36 #include "chrome/test/base/testing_profile.h" | 36 #include "chrome/test/base/testing_profile.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/test/test_browser_thread.h" | 38 #include "content/public/test/test_browser_thread.h" |
39 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
41 | 41 |
42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
43 #include "chrome/browser/chromeos/cros/cros_library.h" | |
44 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 43 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
45 #include "chrome/browser/chromeos/login/user_manager.h" | 44 #include "chrome/browser/chromeos/login/user_manager.h" |
46 #include "chrome/browser/chromeos/settings/cros_settings.h" | 45 #include "chrome/browser/chromeos/settings/cros_settings.h" |
47 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 46 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
48 #include "chromeos/chromeos_switches.h" | 47 #include "chromeos/chromeos_switches.h" |
49 #endif | 48 #endif |
50 | 49 |
51 using content::BrowserThread; | 50 using content::BrowserThread; |
52 | 51 |
53 namespace { | 52 namespace { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 public: | 93 public: |
95 MOCK_METHOD2(OnProfileCreated, | 94 MOCK_METHOD2(OnProfileCreated, |
96 void(Profile* profile, Profile::CreateStatus status)); | 95 void(Profile* profile, Profile::CreateStatus status)); |
97 }; | 96 }; |
98 | 97 |
99 ProfileManagerTest() | 98 ProfileManagerTest() |
100 : local_state_(TestingBrowserProcess::GetGlobal()), | 99 : local_state_(TestingBrowserProcess::GetGlobal()), |
101 extension_event_router_forwarder_(new extensions::EventRouterForwarder), | 100 extension_event_router_forwarder_(new extensions::EventRouterForwarder), |
102 ui_thread_(BrowserThread::UI, &message_loop_), | 101 ui_thread_(BrowserThread::UI, &message_loop_), |
103 db_thread_(BrowserThread::DB, &message_loop_), | 102 db_thread_(BrowserThread::DB, &message_loop_), |
104 file_thread_(BrowserThread::FILE, &message_loop_), | 103 file_thread_(BrowserThread::FILE, &message_loop_) { |
105 io_thread_(local_state_.Get(), | |
106 g_browser_process->policy_service(), | |
107 NULL, | |
108 extension_event_router_forwarder_.get()) { | |
109 TestingBrowserProcess::GetGlobal()->SetIOThread(&io_thread_); | |
110 } | 104 } |
111 | 105 |
112 virtual void SetUp() { | 106 virtual void SetUp() { |
113 // Create a new temporary directory, and store the path | 107 // Create a new temporary directory, and store the path |
114 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 108 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
115 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 109 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
116 new testing::ProfileManager(temp_dir_.path())); | 110 new testing::ProfileManager(temp_dir_.path())); |
117 | 111 |
118 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
119 CommandLine* cl = CommandLine::ForCurrentProcess(); | 113 CommandLine* cl = CommandLine::ForCurrentProcess(); |
120 cl->AppendSwitch(switches::kTestType); | 114 cl->AppendSwitch(switches::kTestType); |
121 #endif | 115 #endif |
122 } | 116 } |
123 | 117 |
124 virtual void TearDown() { | 118 virtual void TearDown() { |
125 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); | 119 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
126 message_loop_.RunUntilIdle(); | 120 message_loop_.RunUntilIdle(); |
127 } | 121 } |
128 | 122 |
129 #if defined(OS_CHROMEOS) | 123 #if defined(OS_CHROMEOS) |
130 // Do not change order of stub_cros_enabler_, which needs to be constructed | |
131 // before io_thread_ which requires CrosLibrary to be initialized to construct | |
132 // its data member pref_proxy_config_tracker_ on ChromeOS. | |
133 chromeos::ScopedStubCrosEnabler stub_cros_enabler_; | |
134 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 124 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
135 chromeos::ScopedTestCrosSettings test_cros_settings_; | 125 chromeos::ScopedTestCrosSettings test_cros_settings_; |
136 #endif | 126 #endif |
137 | 127 |
138 // The path to temporary directory used to contain the test operations. | 128 // The path to temporary directory used to contain the test operations. |
139 base::ScopedTempDir temp_dir_; | 129 base::ScopedTempDir temp_dir_; |
140 ScopedTestingLocalState local_state_; | 130 ScopedTestingLocalState local_state_; |
141 scoped_refptr<extensions::EventRouterForwarder> | 131 scoped_refptr<extensions::EventRouterForwarder> |
142 extension_event_router_forwarder_; | 132 extension_event_router_forwarder_; |
143 | 133 |
144 base::MessageLoopForUI message_loop_; | 134 base::MessageLoopForUI message_loop_; |
145 content::TestBrowserThread ui_thread_; | 135 content::TestBrowserThread ui_thread_; |
146 content::TestBrowserThread db_thread_; | 136 content::TestBrowserThread db_thread_; |
147 content::TestBrowserThread file_thread_; | 137 content::TestBrowserThread file_thread_; |
148 // IOThread is necessary for the creation of some services below. | |
149 IOThread io_thread_; | |
150 | 138 |
151 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
152 chromeos::ScopedTestUserManager test_user_manager_; | 140 chromeos::ScopedTestUserManager test_user_manager_; |
153 #endif | 141 #endif |
154 }; | 142 }; |
155 | 143 |
156 TEST_F(ProfileManagerTest, GetProfile) { | 144 TEST_F(ProfileManagerTest, GetProfile) { |
157 base::FilePath dest_path = temp_dir_.path(); | 145 base::FilePath dest_path = temp_dir_.path(); |
158 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); | 146 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); |
159 | 147 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 browser2b.reset(); | 633 browser2b.reset(); |
646 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 634 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
647 ASSERT_EQ(1U, last_opened_profiles.size()); | 635 ASSERT_EQ(1U, last_opened_profiles.size()); |
648 EXPECT_EQ(profile1, last_opened_profiles[0]); | 636 EXPECT_EQ(profile1, last_opened_profiles[0]); |
649 | 637 |
650 browser1.reset(); | 638 browser1.reset(); |
651 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 639 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
652 ASSERT_EQ(0U, last_opened_profiles.size()); | 640 ASSERT_EQ(0U, last_opened_profiles.size()); |
653 } | 641 } |
654 #endif // !defined(OS_ANDROID) | 642 #endif // !defined(OS_ANDROID) |
OLD | NEW |