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

Side by Side Diff: net/proxy/proxy_config_service_linux_unittest.cc

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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"
6
5 #include <map> 7 #include <map>
6 #include <string> 8 #include <string>
7 #include <vector> 9 #include <vector>
8 10
9 #include "net/proxy/proxy_config_service_linux.h"
10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/format_macros.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "base/task.h" 16 #include "base/task.h"
16 #include "base/thread.h" 17 #include "base/thread.h"
17 #include "base/waitable_event.h" 18 #include "base/waitable_event.h"
18 #include "net/proxy/proxy_config.h" 19 #include "net/proxy/proxy_config.h"
19 #include "net/proxy/proxy_config_service_common_unittest.h" 20 #include "net/proxy/proxy_config_service_common_unittest.h"
20
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/platform_test.h" 22 #include "testing/platform_test.h"
23 23
24 namespace net { 24 namespace net {
25 namespace { 25 namespace {
26 26
27 // Set of values for all environment variables that we might 27 // Set of values for all environment variables that we might
28 // query. NULL represents an unset variable. 28 // query. NULL represents an unset variable.
29 struct EnvVarValues { 29 struct EnvVarValues {
30 // The strange capitalization is so that the field matches the 30 // The strange capitalization is so that the field matches the
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 578
579 false, // auto_detect 579 false, // auto_detect
580 GURL(), // pac_url 580 GURL(), // pac_url
581 MakeSingleProxyRules("www.google.com"), // proxy_rules 581 MakeSingleProxyRules("www.google.com"), // proxy_rules
582 "*.google.com\n", // proxy_bypass_list 582 "*.google.com\n", // proxy_bypass_list
583 false, // bypass_local_names 583 false, // bypass_local_names
584 }, 584 },
585 }; 585 };
586 586
587 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 587 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
588 SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str())); 588 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
589 tests[i].description.c_str()));
589 MockEnvironmentVariableGetter* env_getter = 590 MockEnvironmentVariableGetter* env_getter =
590 new MockEnvironmentVariableGetter; 591 new MockEnvironmentVariableGetter;
591 MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter; 592 MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
592 SynchConfigGetter sync_config_getter( 593 SynchConfigGetter sync_config_getter(
593 new ProxyConfigServiceLinux(env_getter, gconf_getter)); 594 new ProxyConfigServiceLinux(env_getter, gconf_getter));
594 ProxyConfig config; 595 ProxyConfig config;
595 gconf_getter->values = tests[i].values; 596 gconf_getter->values = tests[i].values;
596 sync_config_getter.SetupAndInitialFetch(); 597 sync_config_getter.SetupAndInitialFetch();
597 sync_config_getter.SyncGetProxyConfig(&config); 598 sync_config_getter.SyncGetProxyConfig(&config);
598 599
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 false, // auto_detect 858 false, // auto_detect
858 GURL(), // pac_url 859 GURL(), // pac_url
859 MakeSingleProxyRules("www.google.com"), // proxy_rules 860 MakeSingleProxyRules("www.google.com"), // proxy_rules
860 // proxy_bypass_list 861 // proxy_bypass_list
861 "*.google.com\n*foo.com:99\n1.2.3.4:22\n127.0.0.1/8\n", 862 "*.google.com\n*foo.com:99\n1.2.3.4:22\n127.0.0.1/8\n",
862 false, // bypass_local_names 863 false, // bypass_local_names
863 }, 864 },
864 }; 865 };
865 866
866 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 867 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
867 SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str())); 868 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
869 tests[i].description.c_str()));
868 MockEnvironmentVariableGetter* env_getter = 870 MockEnvironmentVariableGetter* env_getter =
869 new MockEnvironmentVariableGetter; 871 new MockEnvironmentVariableGetter;
870 MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter; 872 MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
871 SynchConfigGetter sync_config_getter( 873 SynchConfigGetter sync_config_getter(
872 new ProxyConfigServiceLinux(env_getter, gconf_getter)); 874 new ProxyConfigServiceLinux(env_getter, gconf_getter));
873 ProxyConfig config; 875 ProxyConfig config;
874 env_getter->values = tests[i].values; 876 env_getter->values = tests[i].values;
875 sync_config_getter.SetupAndInitialFetch(); 877 sync_config_getter.SetupAndInitialFetch();
876 sync_config_getter.SyncGetProxyConfig(&config); 878 sync_config_getter.SyncGetProxyConfig(&config);
877 879
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 false, // auto_detect 1180 false, // auto_detect
1179 GURL(), // pac_url 1181 GURL(), // pac_url
1180 MakeProxyPerSchemeRules("www.google.com", 1182 MakeProxyPerSchemeRules("www.google.com",
1181 "", "ftp.foo.com"), // proxy_rules 1183 "", "ftp.foo.com"), // proxy_rules
1182 "", // proxy_bypass_list 1184 "", // proxy_bypass_list
1183 false, // bypass_local_names 1185 false, // bypass_local_names
1184 }, 1186 },
1185 }; 1187 };
1186 1188
1187 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 1189 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
1188 SCOPED_TRACE(StringPrintf("Test[%d] %s", i, tests[i].description.c_str())); 1190 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
1191 tests[i].description.c_str()));
1189 MockEnvironmentVariableGetter* env_getter = 1192 MockEnvironmentVariableGetter* env_getter =
1190 new MockEnvironmentVariableGetter; 1193 new MockEnvironmentVariableGetter;
1191 // Force the KDE getter to be used and tell it where the test is. 1194 // Force the KDE getter to be used and tell it where the test is.
1192 env_getter->values.DESKTOP_SESSION = "kde"; 1195 env_getter->values.DESKTOP_SESSION = "kde";
1193 env_getter->values.KDE_HOME = kde_home_.value().c_str(); 1196 env_getter->values.KDE_HOME = kde_home_.value().c_str();
1194 SynchConfigGetter sync_config_getter( 1197 SynchConfigGetter sync_config_getter(
1195 new ProxyConfigServiceLinux(env_getter)); 1198 new ProxyConfigServiceLinux(env_getter));
1196 ProxyConfig config; 1199 ProxyConfig config;
1197 // Overwrite the kioslaverc file. 1200 // Overwrite the kioslaverc file.
1198 file_util::WriteFile(kioslaverc_, tests[i].kioslaverc.c_str(), 1201 file_util::WriteFile(kioslaverc_, tests[i].kioslaverc.c_str(),
1199 tests[i].kioslaverc.length()); 1202 tests[i].kioslaverc.length());
1200 sync_config_getter.SetupAndInitialFetch(); 1203 sync_config_getter.SetupAndInitialFetch();
1201 sync_config_getter.SyncGetProxyConfig(&config); 1204 sync_config_getter.SyncGetProxyConfig(&config);
1202 1205
1203 EXPECT_EQ(tests[i].auto_detect, config.auto_detect); 1206 EXPECT_EQ(tests[i].auto_detect, config.auto_detect);
1204 EXPECT_EQ(tests[i].pac_url, config.pac_url); 1207 EXPECT_EQ(tests[i].pac_url, config.pac_url);
1205 EXPECT_EQ(tests[i].proxy_bypass_list, 1208 EXPECT_EQ(tests[i].proxy_bypass_list,
1206 FlattenProxyBypass(config.proxy_bypass)); 1209 FlattenProxyBypass(config.proxy_bypass));
1207 EXPECT_EQ(tests[i].bypass_local_names, config.proxy_bypass_local_names); 1210 EXPECT_EQ(tests[i].bypass_local_names, config.proxy_bypass_local_names);
1208 EXPECT_EQ(tests[i].proxy_rules, config.proxy_rules); 1211 EXPECT_EQ(tests[i].proxy_rules, config.proxy_rules);
1209 } 1212 }
1210 } 1213 }
1211 1214
1212 } // namespace net 1215 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698