Index: ppapi/tests/test_network_proxy.cc |
diff --git a/ppapi/tests/test_network_proxy.cc b/ppapi/tests/test_network_proxy.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7d1a7f78247dd6858f21906fa18698d8c218f969 |
--- /dev/null |
+++ b/ppapi/tests/test_network_proxy.cc |
@@ -0,0 +1,69 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ppapi/tests/test_network_proxy.h" |
+ |
+#include "ppapi/cpp/dev/network_proxy_dev.h" |
+#include "ppapi/cpp/instance.h" |
+#include "ppapi/cpp/module.h" |
yzshen1
2013/06/16 23:49:53
This include is not needed.
dmichael (off chromium)
2013/06/17 21:48:28
Done.
|
+#include "ppapi/cpp/var.h" |
+#include "ppapi/tests/testing_instance.h" |
+ |
+REGISTER_TEST_CASE(NetworkProxy); |
+ |
+TestNetworkProxy::TestNetworkProxy(TestingInstance* instance) |
+ : TestCase(instance) { |
+} |
+ |
+void TestNetworkProxy::RunTests(const std::string& filter) { |
+ RUN_CALLBACK_TEST(TestNetworkProxy, GetProxyForURL, filter); |
+} |
+ |
+std::string TestNetworkProxy::TestGetProxyForURL() { |
+ TestCompletionCallbackWithOutput<pp::Var> callback(instance_->pp_instance(), |
+ callback_type()); |
+ callback.WaitForResult( |
+ pp::NetworkProxy::GetProxyForURL(instance_, |
+ "http://127.0.0.1/foobar/", |
+ callback.GetCallback())); |
+ CHECK_CALLBACK_BEHAVIOR(callback); |
+ ASSERT_EQ(PP_OK, callback.result()); |
+ pp::Var output = callback.output(); |
+ ASSERT_TRUE(output.is_string()); |
+ // Assume no one configures a proxy for localhost. |
+ ASSERT_EQ("DIRECT", callback.output().AsString()); |
+ |
+ callback.WaitForResult( |
+ pp::NetworkProxy::GetProxyForURL(instance_, |
+ "http://www.google.com", |
+ callback.GetCallback())); |
+ CHECK_CALLBACK_BEHAVIOR(callback); |
+ ASSERT_EQ(PP_OK, callback.result()); |
+ output = callback.output(); |
+ // Don't know what the proxy might be, but it should be a valid result. |
+ ASSERT_TRUE(output.is_string()); |
+ |
+ callback.WaitForResult( |
+ pp::NetworkProxy::GetProxyForURL(instance_, |
+ "file:///tmp", |
+ callback.GetCallback())); |
+ CHECK_CALLBACK_BEHAVIOR(callback); |
+ ASSERT_EQ(PP_OK, callback.result()); |
+ output = callback.output(); |
+ ASSERT_TRUE(output.is_string()); |
+ // Should get "DIRECT" for file:// URLs. |
+ ASSERT_EQ("DIRECT", output.AsString()); |
+ |
+ callback.WaitForResult( |
+ pp::NetworkProxy::GetProxyForURL(instance_, |
+ "this isn't a url", |
+ callback.GetCallback())); |
+ CHECK_CALLBACK_BEHAVIOR(callback); |
+ // TODO(dmichael): Use bad address when it's available. |
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); |
+ // TODO(dmichael): Add this check below when crbug.com/250046 is fixed. |
+ // ASSERT_TRUE(callback.output().is_undefined()); |
+ |
+ PASS(); |
+} |