Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/tests/test_network_proxy.h" | |
| 6 | |
| 7 #include "ppapi/cpp/dev/network_proxy_dev.h" | |
| 8 #include "ppapi/cpp/instance.h" | |
| 9 #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.
| |
| 10 #include "ppapi/cpp/var.h" | |
| 11 #include "ppapi/tests/testing_instance.h" | |
| 12 | |
| 13 REGISTER_TEST_CASE(NetworkProxy); | |
| 14 | |
| 15 TestNetworkProxy::TestNetworkProxy(TestingInstance* instance) | |
| 16 : TestCase(instance) { | |
| 17 } | |
| 18 | |
| 19 void TestNetworkProxy::RunTests(const std::string& filter) { | |
| 20 RUN_CALLBACK_TEST(TestNetworkProxy, GetProxyForURL, filter); | |
| 21 } | |
| 22 | |
| 23 std::string TestNetworkProxy::TestGetProxyForURL() { | |
| 24 TestCompletionCallbackWithOutput<pp::Var> callback(instance_->pp_instance(), | |
| 25 callback_type()); | |
| 26 callback.WaitForResult( | |
| 27 pp::NetworkProxy::GetProxyForURL(instance_, | |
| 28 "http://127.0.0.1/foobar/", | |
| 29 callback.GetCallback())); | |
| 30 CHECK_CALLBACK_BEHAVIOR(callback); | |
| 31 ASSERT_EQ(PP_OK, callback.result()); | |
| 32 pp::Var output = callback.output(); | |
| 33 ASSERT_TRUE(output.is_string()); | |
| 34 // Assume no one configures a proxy for localhost. | |
| 35 ASSERT_EQ("DIRECT", callback.output().AsString()); | |
| 36 | |
| 37 callback.WaitForResult( | |
| 38 pp::NetworkProxy::GetProxyForURL(instance_, | |
| 39 "http://www.google.com", | |
| 40 callback.GetCallback())); | |
| 41 CHECK_CALLBACK_BEHAVIOR(callback); | |
| 42 ASSERT_EQ(PP_OK, callback.result()); | |
| 43 output = callback.output(); | |
| 44 // Don't know what the proxy might be, but it should be a valid result. | |
| 45 ASSERT_TRUE(output.is_string()); | |
| 46 | |
| 47 callback.WaitForResult( | |
| 48 pp::NetworkProxy::GetProxyForURL(instance_, | |
| 49 "file:///tmp", | |
| 50 callback.GetCallback())); | |
| 51 CHECK_CALLBACK_BEHAVIOR(callback); | |
| 52 ASSERT_EQ(PP_OK, callback.result()); | |
| 53 output = callback.output(); | |
| 54 ASSERT_TRUE(output.is_string()); | |
| 55 // Should get "DIRECT" for file:// URLs. | |
| 56 ASSERT_EQ("DIRECT", output.AsString()); | |
| 57 | |
| 58 callback.WaitForResult( | |
| 59 pp::NetworkProxy::GetProxyForURL(instance_, | |
| 60 "this isn't a url", | |
| 61 callback.GetCallback())); | |
| 62 CHECK_CALLBACK_BEHAVIOR(callback); | |
| 63 // TODO(dmichael): Use bad address when it's available. | |
| 64 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); | |
| 65 // TODO(dmichael): Add this check below when crbug.com/250046 is fixed. | |
| 66 // ASSERT_TRUE(callback.output().is_undefined()); | |
| 67 | |
| 68 PASS(); | |
| 69 } | |
| OLD | NEW |