| 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 "net/proxy/proxy_config_service_linux.h" | 5 #include "net/proxy/proxy_config_service_linux.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 class ProxyConfigServiceLinuxTest : public PlatformTest { | 353 class ProxyConfigServiceLinuxTest : public PlatformTest { |
| 354 protected: | 354 protected: |
| 355 virtual void SetUp() OVERRIDE { | 355 virtual void SetUp() OVERRIDE { |
| 356 PlatformTest::SetUp(); | 356 PlatformTest::SetUp(); |
| 357 // Set up a temporary KDE home directory. | 357 // Set up a temporary KDE home directory. |
| 358 std::string prefix("ProxyConfigServiceLinuxTest_user_home"); | 358 std::string prefix("ProxyConfigServiceLinuxTest_user_home"); |
| 359 base::CreateNewTempDirectory(prefix, &user_home_); | 359 base::CreateNewTempDirectory(prefix, &user_home_); |
| 360 kde_home_ = user_home_.Append(FILE_PATH_LITERAL(".kde")); | 360 kde_home_ = user_home_.Append(FILE_PATH_LITERAL(".kde")); |
| 361 base::FilePath path = kde_home_.Append(FILE_PATH_LITERAL("share")); | 361 base::FilePath path = kde_home_.Append(FILE_PATH_LITERAL("share")); |
| 362 path = path.Append(FILE_PATH_LITERAL("config")); | 362 path = path.Append(FILE_PATH_LITERAL("config")); |
| 363 file_util::CreateDirectory(path); | 363 base::CreateDirectory(path); |
| 364 kioslaverc_ = path.Append(FILE_PATH_LITERAL("kioslaverc")); | 364 kioslaverc_ = path.Append(FILE_PATH_LITERAL("kioslaverc")); |
| 365 // Set up paths but do not create the directory for .kde4. | 365 // Set up paths but do not create the directory for .kde4. |
| 366 kde4_home_ = user_home_.Append(FILE_PATH_LITERAL(".kde4")); | 366 kde4_home_ = user_home_.Append(FILE_PATH_LITERAL(".kde4")); |
| 367 path = kde4_home_.Append(FILE_PATH_LITERAL("share")); | 367 path = kde4_home_.Append(FILE_PATH_LITERAL("share")); |
| 368 kde4_config_ = path.Append(FILE_PATH_LITERAL("config")); | 368 kde4_config_ = path.Append(FILE_PATH_LITERAL("config")); |
| 369 kioslaverc4_ = kde4_config_.Append(FILE_PATH_LITERAL("kioslaverc")); | 369 kioslaverc4_ = kde4_config_.Append(FILE_PATH_LITERAL("kioslaverc")); |
| 370 } | 370 } |
| 371 | 371 |
| 372 virtual void TearDown() OVERRIDE { | 372 virtual void TearDown() OVERRIDE { |
| 373 // Delete the temporary KDE home directory. | 373 // Delete the temporary KDE home directory. |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 ProxyConfig config; | 1541 ProxyConfig config; |
| 1542 sync_config_getter.SetupAndInitialFetch(); | 1542 sync_config_getter.SetupAndInitialFetch(); |
| 1543 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, | 1543 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, |
| 1544 sync_config_getter.SyncGetLatestProxyConfig(&config)); | 1544 sync_config_getter.SyncGetLatestProxyConfig(&config)); |
| 1545 EXPECT_TRUE(config.auto_detect()); | 1545 EXPECT_TRUE(config.auto_detect()); |
| 1546 EXPECT_EQ(GURL(), config.pac_url()); | 1546 EXPECT_EQ(GURL(), config.pac_url()); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 // Now create .kde4 and put a kioslaverc in the config directory. | 1549 // Now create .kde4 and put a kioslaverc in the config directory. |
| 1550 // Note that its timestamp will be at least as new as the .kde one. | 1550 // Note that its timestamp will be at least as new as the .kde one. |
| 1551 file_util::CreateDirectory(kde4_config_); | 1551 base::CreateDirectory(kde4_config_); |
| 1552 file_util::WriteFile(kioslaverc4_, slaverc4.c_str(), slaverc4.length()); | 1552 file_util::WriteFile(kioslaverc4_, slaverc4.c_str(), slaverc4.length()); |
| 1553 CHECK(base::PathExists(kioslaverc4_)); | 1553 CHECK(base::PathExists(kioslaverc4_)); |
| 1554 | 1554 |
| 1555 { SCOPED_TRACE("KDE4, .kde4 directory present, use it"); | 1555 { SCOPED_TRACE("KDE4, .kde4 directory present, use it"); |
| 1556 MockEnvironment* env = new MockEnvironment; | 1556 MockEnvironment* env = new MockEnvironment; |
| 1557 env->values.DESKTOP_SESSION = "kde4"; | 1557 env->values.DESKTOP_SESSION = "kde4"; |
| 1558 env->values.HOME = user_home_.value().c_str(); | 1558 env->values.HOME = user_home_.value().c_str(); |
| 1559 SynchConfigGetter sync_config_getter( | 1559 SynchConfigGetter sync_config_getter( |
| 1560 new ProxyConfigServiceLinux(env)); | 1560 new ProxyConfigServiceLinux(env)); |
| 1561 ProxyConfig config; | 1561 ProxyConfig config; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 ProxyConfig config; | 1608 ProxyConfig config; |
| 1609 sync_config_getter.SetupAndInitialFetch(); | 1609 sync_config_getter.SetupAndInitialFetch(); |
| 1610 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, | 1610 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, |
| 1611 sync_config_getter.SyncGetLatestProxyConfig(&config)); | 1611 sync_config_getter.SyncGetLatestProxyConfig(&config)); |
| 1612 EXPECT_TRUE(config.auto_detect()); | 1612 EXPECT_TRUE(config.auto_detect()); |
| 1613 EXPECT_EQ(GURL(), config.pac_url()); | 1613 EXPECT_EQ(GURL(), config.pac_url()); |
| 1614 } | 1614 } |
| 1615 } | 1615 } |
| 1616 | 1616 |
| 1617 } // namespace net | 1617 } // namespace net |
| OLD | NEW |