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

Unified Diff: net/proxy/proxy_resolver_mojo_unittest.cc

Issue 939503004: Add LoadState reporting to the mojo proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-resolver-mojo
Patch Set: rebase Created 5 years, 9 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_resolver_mojo.cc ('k') | net/proxy/proxy_resolver_v8_tracing.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_mojo_unittest.cc
diff --git a/net/proxy/proxy_resolver_mojo_unittest.cc b/net/proxy/proxy_resolver_mojo_unittest.cc
index 2933bb3db8dd06d190e94dbe87ed5f4bf8ce5c20..ffb3b315066cc6ad932bb563ea0d84be04edae11 100644
--- a/net/proxy/proxy_resolver_mojo_unittest.cc
+++ b/net/proxy/proxy_resolver_mojo_unittest.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "mojo/common/common_type_converters.h"
@@ -66,6 +67,8 @@ struct GetProxyForUrlAction {
DISCONNECT,
// Wait for the client pipe to be disconnected.
WAIT_FOR_CLIENT_DISCONNECT,
+ // Send a LoadStateChanged message and keep the client pipe open.
+ SEND_LOAD_STATE_AND_BLOCK,
};
GetProxyForUrlAction() {}
@@ -113,6 +116,13 @@ struct GetProxyForUrlAction {
return result;
}
+ static GetProxyForUrlAction SendLoadStateChanged(const GURL& url) {
+ GetProxyForUrlAction result;
+ result.expected_url = url;
+ result.action = SEND_LOAD_STATE_AND_BLOCK;
+ return result;
+ }
+
Action action = COMPLETE;
Error error = OK;
mojo::Array<interfaces::ProxyServerPtr> proxy_servers;
@@ -133,6 +143,8 @@ class MockMojoProxyResolver : public interfaces::ProxyResolver {
void WaitForNextRequest();
+ void ClearBlockedClients();
+
private:
// Overridden from interfaces::ProxyResolver:
void SetPacScript(const mojo::String& data,
@@ -150,6 +162,7 @@ class MockMojoProxyResolver : public interfaces::ProxyResolver {
base::Closure quit_closure_;
+ ScopedVector<interfaces::ProxyResolverRequestClientPtr> blocked_clients_;
mojo::Binding<interfaces::ProxyResolver> binding_;
};
@@ -205,6 +218,10 @@ void MockMojoProxyResolver::SetPacScript(
WakeWaiter();
}
+void MockMojoProxyResolver::ClearBlockedClients() {
+ blocked_clients_.clear();
+}
+
void MockMojoProxyResolver::GetProxyForUrl(
const mojo::String& url,
interfaces::ProxyResolverRequestClientPtr client) {
@@ -226,6 +243,11 @@ void MockMojoProxyResolver::GetProxyForUrl(
case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT:
ASSERT_FALSE(client.WaitForIncomingMethodCall());
break;
+ case GetProxyForUrlAction::SEND_LOAD_STATE_AND_BLOCK:
+ client->LoadStateChanged(LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT);
+ blocked_clients_.push_back(
+ new interfaces::ProxyResolverRequestClientPtr(client.Pass()));
+ break;
}
WakeWaiter();
}
@@ -303,6 +325,7 @@ class Request {
int error() const { return error_; }
const ProxyInfo& results() const { return results_; }
+ LoadState load_state() { return resolver_->GetLoadState(handle_); }
private:
ProxyResolverMojo* resolver_;
@@ -522,6 +545,21 @@ TEST_F(ProxyResolverMojoTest, GetProxyForURL_WithoutSetPacScript) {
EXPECT_EQ(ERR_PAC_SCRIPT_TERMINATED, request->Resolve());
}
+TEST_F(ProxyResolverMojoTest, GetProxyForURL_LoadState) {
+ mojo_proxy_resolver_factory_.AddFutureGetProxyAction(
+ 0, GetProxyForUrlAction::SendLoadStateChanged(GURL(kExampleUrl)));
+ SetPacScript(0);
+
+ scoped_ptr<Request> request(MakeRequest(GURL(kExampleUrl)));
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, request->load_state());
+ while (request->load_state() == LOAD_STATE_RESOLVING_PROXY_FOR_URL)
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT, request->load_state());
+ mojo_proxy_resolver_factory_.GetMockResolver().ClearBlockedClients();
+ EXPECT_EQ(ERR_PAC_SCRIPT_TERMINATED, request->WaitForResult());
+}
+
TEST_F(ProxyResolverMojoTest, GetProxyForURL_MultipleResults) {
static const char kPacString[] =
"PROXY foo1:80;DIRECT;SOCKS foo2:1234;"
« no previous file with comments | « net/proxy/proxy_resolver_mojo.cc ('k') | net/proxy/proxy_resolver_v8_tracing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698