cc: Include Blink's display list memory usage in rasterize_and_record_micro results.
[chromium-blink-merge.git] / ppapi / tests / test_network_proxy.cc
blob24ec9f1cbe32a813c1b579423659468079d608a2
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.
5 #include "ppapi/tests/test_network_proxy.h"
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/network_proxy.h"
9 #include "ppapi/cpp/var.h"
10 #include "ppapi/tests/testing_instance.h"
12 REGISTER_TEST_CASE(NetworkProxy);
14 TestNetworkProxy::TestNetworkProxy(TestingInstance* instance)
15 : TestCase(instance) {
18 void TestNetworkProxy::RunTests(const std::string& filter) {
19 RUN_CALLBACK_TEST(TestNetworkProxy, GetProxyForURL, filter);
22 std::string TestNetworkProxy::TestGetProxyForURL() {
23 TestCompletionCallbackWithOutput<pp::Var> callback(instance_->pp_instance(),
24 callback_type());
25 callback.WaitForResult(
26 pp::NetworkProxy::GetProxyForURL(instance_,
27 pp::Var("http://127.0.0.1/foobar/"),
28 callback.GetCallback()));
29 CHECK_CALLBACK_BEHAVIOR(callback);
30 ASSERT_EQ(PP_OK, callback.result());
31 pp::Var output = callback.output();
32 ASSERT_TRUE(output.is_string());
33 // Assume no one configures a proxy for localhost.
34 ASSERT_EQ("DIRECT", callback.output().AsString());
36 callback.WaitForResult(
37 pp::NetworkProxy::GetProxyForURL(instance_,
38 pp::Var("http://www.google.com"),
39 callback.GetCallback()));
40 CHECK_CALLBACK_BEHAVIOR(callback);
41 ASSERT_EQ(PP_OK, callback.result());
42 output = callback.output();
43 // Don't know what the proxy might be, but it should be a valid result.
44 ASSERT_TRUE(output.is_string());
46 callback.WaitForResult(
47 pp::NetworkProxy::GetProxyForURL(instance_,
48 pp::Var("file:///tmp"),
49 callback.GetCallback()));
50 CHECK_CALLBACK_BEHAVIOR(callback);
51 ASSERT_EQ(PP_OK, callback.result());
52 output = callback.output();
53 ASSERT_TRUE(output.is_string());
54 // Should get "DIRECT" for file:// URLs.
55 ASSERT_EQ("DIRECT", output.AsString());
57 callback.WaitForResult(
58 pp::NetworkProxy::GetProxyForURL(instance_,
59 pp::Var("this isn't a url"),
60 callback.GetCallback()));
61 CHECK_CALLBACK_BEHAVIOR(callback);
62 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
63 ASSERT_TRUE(callback.output().is_undefined());
65 callback.WaitForResult(
66 pp::NetworkProxy::GetProxyForURL(instance_,
67 pp::Var(42), // non-string Var
68 callback.GetCallback()));
69 CHECK_CALLBACK_BEHAVIOR(callback);
70 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
71 ASSERT_TRUE(callback.output().is_undefined());
73 PASS();