| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_url_util.h" | 5 #include "ppapi/tests/test_url_util.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_url_util_dev.h" | 7 #include "ppapi/c/dev/ppb_url_util_dev.h" |
| 8 #include "ppapi/cpp/dev/url_util_dev.h" | 8 #include "ppapi/cpp/dev/url_util_dev.h" |
| 9 #include "ppapi/tests/testing_instance.h" | 9 #include "ppapi/tests/testing_instance.h" |
| 10 | 10 |
| 11 REGISTER_TEST_CASE(URLUtil); | 11 REGISTER_TEST_CASE(URLUtil); |
| 12 | 12 |
| 13 static bool ComponentEquals(const PP_URLComponent_Dev& component, | 13 static bool ComponentEquals(const PP_URLComponent_Dev& component, |
| 14 int begin, int len) { | 14 int begin, int len) { |
| 15 return component.begin == begin && component.len == len; | 15 return component.begin == begin && component.len == len; |
| 16 } | 16 } |
| 17 | 17 |
| 18 bool TestURLUtil::Init() { | 18 bool TestURLUtil::Init() { |
| 19 util_ = pp::URLUtil_Dev::Get(); | 19 util_ = pp::URLUtil_Dev::Get(); |
| 20 return !!util_; | 20 return !!util_; |
| 21 } | 21 } |
| 22 | 22 |
| 23 void TestURLUtil::RunTest() { | 23 void TestURLUtil::RunTests(const std::string& filter) { |
| 24 RUN_TEST(Canonicalize); | 24 RUN_TEST(Canonicalize, filter); |
| 25 RUN_TEST(ResolveRelative); | 25 RUN_TEST(ResolveRelative, filter); |
| 26 RUN_TEST(IsSameSecurityOrigin); | 26 RUN_TEST(IsSameSecurityOrigin, filter); |
| 27 RUN_TEST(DocumentCanRequest); | 27 RUN_TEST(DocumentCanRequest, filter); |
| 28 RUN_TEST(DocumentCanAccessDocument); | 28 RUN_TEST(DocumentCanAccessDocument, filter); |
| 29 RUN_TEST(GetDocumentURL); | 29 RUN_TEST(GetDocumentURL, filter); |
| 30 RUN_TEST(GetPluginInstanceURL); | 30 RUN_TEST(GetPluginInstanceURL, filter); |
| 31 } | 31 } |
| 32 | 32 |
| 33 std::string TestURLUtil::TestCanonicalize() { | 33 std::string TestURLUtil::TestCanonicalize() { |
| 34 // Test no canonicalize output. | 34 // Test no canonicalize output. |
| 35 pp::Var result = util_->Canonicalize("http://Google.com"); | 35 pp::Var result = util_->Canonicalize("http://Google.com"); |
| 36 ASSERT_TRUE(result.AsString() == "http://google.com/"); | 36 ASSERT_TRUE(result.AsString() == "http://google.com/"); |
| 37 | 37 |
| 38 // Test all the components | 38 // Test all the components |
| 39 PP_URLComponents_Dev c; | 39 PP_URLComponents_Dev c; |
| 40 result = util_->Canonicalize( | 40 result = util_->Canonicalize( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 PASS(); | 129 PASS(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 std::string TestURLUtil::TestGetPluginInstanceURL() { | 132 std::string TestURLUtil::TestGetPluginInstanceURL() { |
| 133 pp::Var url = util_->GetPluginInstanceURL(*instance_); | 133 pp::Var url = util_->GetPluginInstanceURL(*instance_); |
| 134 ASSERT_TRUE(url.is_string()); | 134 ASSERT_TRUE(url.is_string()); |
| 135 // see test_case.html | 135 // see test_case.html |
| 136 ASSERT_EQ(url.AsString(), "http://a.b.c/test"); | 136 ASSERT_EQ(url.AsString(), "http://a.b.c/test"); |
| 137 PASS(); | 137 PASS(); |
| 138 } | 138 } |
| OLD | NEW |