| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "net/base/data_url.h" | 6 #include "net/base/data_url.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 "text/html", | 81 "text/html", |
| 82 "US-ASCII", | 82 "US-ASCII", |
| 83 "<html><body><b>hello world</b></body></html>" }, | 83 "<html><body><b>hello world</b></body></html>" }, |
| 84 | 84 |
| 85 { "data:text/html,<html><body><b>hello world</b></body></html>", | 85 { "data:text/html,<html><body><b>hello world</b></body></html>", |
| 86 true, | 86 true, |
| 87 "text/html", | 87 "text/html", |
| 88 "US-ASCII", | 88 "US-ASCII", |
| 89 "<html><body><b>hello world</b></body></html>" }, | 89 "<html><body><b>hello world</b></body></html>" }, |
| 90 | 90 |
| 91 // Bad mime type |
| 92 { "data:f(oo/bar;baz=1;charset=kk,boo", |
| 93 false, |
| 94 "", |
| 95 "", |
| 96 "" }, |
| 97 |
| 91 // the comma cannot be url-escaped! | 98 // the comma cannot be url-escaped! |
| 92 { "data:%2Cblah", | 99 { "data:%2Cblah", |
| 93 false, | 100 false, |
| 94 "", | 101 "", |
| 95 "", | 102 "", |
| 96 "" }, | 103 "" }, |
| 97 | 104 |
| 98 // invalid base64 content | 105 // invalid base64 content |
| 99 { "data:;base64,aGVs_-_-", | 106 { "data:;base64,aGVs_-_-", |
| 100 false, | 107 false, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 bool ok = | 179 bool ok = |
| 173 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); | 180 net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data); |
| 174 EXPECT_EQ(ok, tests[i].is_valid); | 181 EXPECT_EQ(ok, tests[i].is_valid); |
| 175 if (tests[i].is_valid) { | 182 if (tests[i].is_valid) { |
| 176 EXPECT_EQ(tests[i].mime_type, mime_type); | 183 EXPECT_EQ(tests[i].mime_type, mime_type); |
| 177 EXPECT_EQ(tests[i].charset, charset); | 184 EXPECT_EQ(tests[i].charset, charset); |
| 178 EXPECT_EQ(tests[i].data, data); | 185 EXPECT_EQ(tests[i].data, data); |
| 179 } | 186 } |
| 180 } | 187 } |
| 181 } | 188 } |
| OLD | NEW |