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

Side by Side Diff: chrome/browser/chromeos/proxy_config_service_impl_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 months 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 "chromeos/network/proxy/proxy_config_service_impl.h" 5 #include "chromeos/network/proxy/proxy_config_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h" 17 #include "base/run_loop.h"
19 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 19 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chrome/browser/chromeos/settings/device_settings_service.h" 20 #include "chrome/browser/chromeos/settings/device_settings_service.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/shill_profile_client.h" 22 #include "chromeos/dbus/shill_profile_client.h"
24 #include "chromeos/dbus/shill_service_client.h" 23 #include "chromeos/dbus/shill_service_client.h"
25 #include "chromeos/network/network_handler.h" 24 #include "chromeos/network/network_handler.h"
26 #include "chromeos/network/network_profile_handler.h" 25 #include "chromeos/network/network_profile_handler.h"
27 #include "chromeos/network/network_state.h" 26 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h" 27 #include "chromeos/network/network_state_handler.h"
29 #include "chromeos/network/onc/onc_utils.h" 28 #include "chromeos/network/onc/onc_utils.h"
30 #include "chromeos/network/proxy/proxy_config_handler.h" 29 #include "chromeos/network/proxy/proxy_config_handler.h"
31 #include "chromeos/network/proxy/ui_proxy_config.h" 30 #include "chromeos/network/proxy/ui_proxy_config.h"
32 #include "components/onc/onc_pref_names.h" 31 #include "components/onc/onc_pref_names.h"
33 #include "components/prefs/testing_pref_service.h" 32 #include "components/prefs/testing_pref_service.h"
34 #include "components/proxy_config/proxy_config_pref_names.h" 33 #include "components/proxy_config/proxy_config_pref_names.h"
35 #include "components/sync_preferences/testing_pref_service_syncable.h" 34 #include "components/sync_preferences/testing_pref_service_syncable.h"
36 #include "content/public/test/test_browser_thread.h" 35 #include "content/public/test/test_browser_thread.h"
36 #include "content/public/test/test_browser_thread_bundle.h"
37 #include "net/proxy/proxy_config.h" 37 #include "net/proxy/proxy_config.h"
38 #include "net/proxy/proxy_config_service_common_unittest.h" 38 #include "net/proxy/proxy_config_service_common_unittest.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 #include "third_party/cros_system_api/dbus/service_constants.h" 40 #include "third_party/cros_system_api/dbus/service_constants.h"
41 41
42 // TODO(stevenjb): Refactor and move this to src/chromeos/network/proxy or 42 // TODO(stevenjb): Refactor and move this to src/chromeos/network/proxy or
43 // rename. This is really more of an integration test than a unit test at this 43 // rename. This is really more of an integration test than a unit test at this
44 // point and currently relies on some chrome specific components. 44 // point and currently relies on some chrome specific components.
45 45
46 using content::BrowserThread; 46 using content::BrowserThread;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 " \"PAC\": \"http://domain.com/x\"," 230 " \"PAC\": \"http://domain.com/x\","
231 " \"Type\": \"PAC\" }" 231 " \"Type\": \"PAC\" }"
232 " }"; 232 " }";
233 233
234 const char kUserProfilePath[] = "user_profile"; 234 const char kUserProfilePath[] = "user_profile";
235 235
236 } // namespace 236 } // namespace
237 237
238 class ProxyConfigServiceImplTest : public testing::Test { 238 class ProxyConfigServiceImplTest : public testing::Test {
239 protected: 239 protected:
240 ProxyConfigServiceImplTest() 240 ProxyConfigServiceImplTest() = default;
241 : ui_thread_(BrowserThread::UI, &loop_),
242 io_thread_(BrowserThread::IO, &loop_) {}
243 241
244 void SetUp() override { 242 void SetUp() override {
245 DBusThreadManager::Initialize(); 243 DBusThreadManager::Initialize();
246 NetworkHandler::Initialize(); 244 NetworkHandler::Initialize();
247 245
248 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service_.registry()); 246 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service_.registry());
249 ::onc::RegisterPrefs(pref_service_.registry()); 247 ::onc::RegisterPrefs(pref_service_.registry());
250 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry()); 248 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry());
251 ::onc::RegisterProfilePrefs(profile_prefs_.registry()); 249 ::onc::RegisterProfilePrefs(profile_prefs_.registry());
252 } 250 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // Let message loop process all messages. This will run 362 // Let message loop process all messages. This will run
365 // ChromeProxyConfigService::UpdateProxyConfig, which is posted on IO from 363 // ChromeProxyConfigService::UpdateProxyConfig, which is posted on IO from
366 // PrefProxyConfigTrackerImpl::OnProxyConfigChanged. 364 // PrefProxyConfigTrackerImpl::OnProxyConfigChanged.
367 base::RunLoop().RunUntilIdle(); 365 base::RunLoop().RunUntilIdle();
368 net::ProxyConfigService::ConfigAvailability availability = 366 net::ProxyConfigService::ConfigAvailability availability =
369 proxy_config_service_->GetLatestProxyConfig(config); 367 proxy_config_service_->GetLatestProxyConfig(config);
370 368
371 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, availability); 369 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, availability);
372 } 370 }
373 371
374 base::MessageLoop loop_; 372 content::TestBrowserThreadBundle test_browser_thread_bundle_;
375 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; 373 std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
376 std::unique_ptr<ProxyConfigServiceImpl> config_service_impl_; 374 std::unique_ptr<ProxyConfigServiceImpl> config_service_impl_;
377 TestingPrefServiceSimple pref_service_; 375 TestingPrefServiceSimple pref_service_;
378 sync_preferences::TestingPrefServiceSyncable profile_prefs_; 376 sync_preferences::TestingPrefServiceSyncable profile_prefs_;
379 377
380 private: 378 private:
381 ScopedTestDeviceSettingsService test_device_settings_service_; 379 ScopedTestDeviceSettingsService test_device_settings_service_;
382 ScopedTestCrosSettings test_cros_settings_; 380 ScopedTestCrosSettings test_cros_settings_;
383 content::TestBrowserThread ui_thread_;
384 content::TestBrowserThread io_thread_;
385 }; 381 };
386 382
387 TEST_F(ProxyConfigServiceImplTest, NetworkProxy) { 383 TEST_F(ProxyConfigServiceImplTest, NetworkProxy) {
388 SetUpPrivateWiFi(); 384 SetUpPrivateWiFi();
389 // Create a ProxyConfigServiceImpl like for the system request context. 385 // Create a ProxyConfigServiceImpl like for the system request context.
390 SetUpProxyConfigService(nullptr /* no profile prefs */); 386 SetUpProxyConfigService(nullptr /* no profile prefs */);
391 for (size_t i = 0; i < arraysize(tests); ++i) { 387 for (size_t i = 0; i < arraysize(tests); ++i) {
392 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "] %s", i, 388 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "] %s", i,
393 tests[i].description.c_str())); 389 tests[i].description.c_str()));
394 390
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 std::move(network_configs)); 525 std::move(network_configs));
530 526
531 net::ProxyConfig actual_config; 527 net::ProxyConfig actual_config;
532 SyncGetLatestProxyConfig(&actual_config); 528 SyncGetLatestProxyConfig(&actual_config);
533 net::ProxyConfig expected_config = 529 net::ProxyConfig expected_config =
534 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); 530 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x"));
535 EXPECT_TRUE(expected_config.Equals(actual_config)); 531 EXPECT_TRUE(expected_config.Equals(actual_config));
536 } 532 }
537 533
538 } // namespace chromeos 534 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698