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

Unified Diff: net/proxy/proxy_service_unittest.cc

Issue 113482: Adding the ability to alter Chrome's proxy settings via the automation interf... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service_unittest.cc
===================================================================
--- net/proxy/proxy_service_unittest.cc (revision 16185)
+++ net/proxy/proxy_service_unittest.cc (working copy)
@@ -138,6 +138,14 @@
started_.Wait();
}
+ void StartResetConfigService(
+ net::ProxyConfigService* new_proxy_config_service) {
+ DCHECK(MessageLoop::current() != io_message_loop_);
+ io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &ResultFuture::DoResetConfigService, new_proxy_config_service));
+ started_.Wait();
+ }
+
// Called on |io_message_loop_|.
void DoStartRequest(const GURL& url, RequestMethod method) {
DCHECK(MessageLoop::current() == io_message_loop_);
@@ -150,6 +158,14 @@
}
// Called on |io_message_loop_|.
+ void DoResetConfigService(net::ProxyConfigService* new_proxy_config_service) {
+ DCHECK(MessageLoop::current() == io_message_loop_);
+ service_->ResetConfigService(new_proxy_config_service);
+ started_.Signal();
+ OnCompletion(0);
+ }
+
+ // Called on |io_message_loop_|.
void DoCancel() {
DCHECK(MessageLoop::current() == io_message_loop_);
if (!did_complete_)
@@ -230,6 +246,13 @@
(*result)->StartReconsider(url, proxy_info);
}
+ void ResetConfigService(scoped_refptr<ResultFuture>* result,
+ net::ProxyConfigService* new_proxy_config_service) {
+ *result = new ResultFuture(io_thread_.message_loop(),
+ io_thread_state_->service);
+ (*result)->StartResetConfigService(new_proxy_config_service);
+ }
+
void SetProxyScriptFetcher(net::ProxyScriptFetcher* proxy_script_fetcher) {
io_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
io_thread_state_.get(), &IOThreadState::DoSetProxyScriptFetcher,
@@ -292,6 +315,12 @@
return result->GetResultCode();
}
+ int ResetConfigService(net::ProxyConfigService* new_proxy_config_service) {
+ scoped_refptr<ResultFuture> result;
+ service_.ResetConfigService(&result, new_proxy_config_service);
+ return result->GetResultCode();
+ }
+
private:
ProxyServiceWithFutures service_;
};
@@ -1096,3 +1125,24 @@
EXPECT_EQ("pac-v1.request3:80",
result3->GetProxyInfo().proxy_server().ToURI());
}
+
+TEST(ProxyServiceTest, ResetProxyConfigService) {
+ net::ProxyConfig config1;
+ config1.proxy_rules.ParseFromString("foopy1:8080");
+ config1.auto_detect = false;
+ scoped_ptr<SyncProxyService> service(
+ new SyncProxyService(new MockProxyConfigService(config1),
+ new MockProxyResolverWithoutFetch));
+
+ net::ProxyInfo info;
+ service->ResolveProxy(GURL("http://request1"), &info);
+ EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
+
+ net::ProxyConfig config2;
+ config2.proxy_rules.ParseFromString("foopy2:8080");
+ config2.auto_detect = false;
+ int result = service->ResetConfigService(new MockProxyConfigService(config2));
+ DCHECK(result == 0);
+ service->ResolveProxy(GURL("http://request2"), &info);
+ EXPECT_EQ("foopy2:8080", info.proxy_server().ToURI());
+}
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698