Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: content/child/blink_platform_impl_unittest.cc

Issue 1544273002: Switch to standard integer types in content/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | content/child/blob_storage/blob_consolidation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <stdint.h>
8
7 #include "base/run_loop.h" 9 #include "base/run_loop.h"
8 #include "base/time/time.h" 10 #include "base/time/time.h"
9 #include "net/base/ip_address_number.h" 11 #include "net/base/ip_address_number.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
12 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
13 #include "url/origin.h" 15 #include "url/origin.h"
14 16
15 namespace content { 17 namespace content {
16 18
(...skipping 27 matching lines...) Expand all
44 EXPECT_TRUE(platform_impl.isReservedIPAddress("[::192.9.5.5]")); 46 EXPECT_TRUE(platform_impl.isReservedIPAddress("[::192.9.5.5]"));
45 EXPECT_TRUE(platform_impl.isReservedIPAddress("[FEED::BEEF]")); 47 EXPECT_TRUE(platform_impl.isReservedIPAddress("[FEED::BEEF]"));
46 EXPECT_TRUE(platform_impl.isReservedIPAddress( 48 EXPECT_TRUE(platform_impl.isReservedIPAddress(
47 "[FEC0:ba98:7654:3210:FEDC:BA98:7654:3210]")); 49 "[FEC0:ba98:7654:3210:FEDC:BA98:7654:3210]"));
48 50
49 // Not IP addresses at all. 51 // Not IP addresses at all.
50 EXPECT_FALSE(platform_impl.isReservedIPAddress("example.com")); 52 EXPECT_FALSE(platform_impl.isReservedIPAddress("example.com"));
51 EXPECT_FALSE(platform_impl.isReservedIPAddress("127.0.0.1.example.com")); 53 EXPECT_FALSE(platform_impl.isReservedIPAddress("127.0.0.1.example.com"));
52 54
53 // Moar IPv4 55 // Moar IPv4
54 uint8 address[4] = {0, 0, 0, 1}; 56 uint8_t address[4] = {0, 0, 0, 1};
55 for (int i = 0; i < 256; i++) { 57 for (int i = 0; i < 256; i++) {
56 address[0] = i; 58 address[0] = i;
57 std::string addressString = 59 std::string addressString =
58 net::IPAddressToString(address, sizeof(address)); 60 net::IPAddressToString(address, sizeof(address));
59 if (i == 0 || i == 10 || i == 127 || i > 223) { 61 if (i == 0 || i == 10 || i == 127 || i > 223) {
60 EXPECT_TRUE(platform_impl.isReservedIPAddress( 62 EXPECT_TRUE(platform_impl.isReservedIPAddress(
61 blink::WebString::fromUTF8(addressString))); 63 blink::WebString::fromUTF8(addressString)));
62 } else { 64 } else {
63 EXPECT_FALSE(platform_impl.isReservedIPAddress( 65 EXPECT_FALSE(platform_impl.isReservedIPAddress(
64 blink::WebString::fromUTF8(addressString))); 66 blink::WebString::fromUTF8(addressString)));
(...skipping 11 matching lines...) Expand all
76 EXPECT_FALSE(platform_impl.portAllowed(GURL("ws://example.com:21"))); 78 EXPECT_FALSE(platform_impl.portAllowed(GURL("ws://example.com:21")));
77 EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:80"))); 79 EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:80")));
78 EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:8889"))); 80 EXPECT_TRUE(platform_impl.portAllowed(GURL("http://example.com:8889")));
79 } 81 }
80 82
81 TEST(BlinkPlatformTest, castWebSecurityOrigin) { 83 TEST(BlinkPlatformTest, castWebSecurityOrigin) {
82 struct TestCase { 84 struct TestCase {
83 const char* origin; 85 const char* origin;
84 const char* scheme; 86 const char* scheme;
85 const char* host; 87 const char* host;
86 uint16 port; 88 uint16_t port;
87 } cases[] = { 89 } cases[] = {
88 {"http://example.com", "http", "example.com", 80}, 90 {"http://example.com", "http", "example.com", 80},
89 {"http://example.com:80", "http", "example.com", 80}, 91 {"http://example.com:80", "http", "example.com", 80},
90 {"http://example.com:81", "http", "example.com", 81}, 92 {"http://example.com:81", "http", "example.com", 81},
91 {"https://example.com", "https", "example.com", 443}, 93 {"https://example.com", "https", "example.com", 443},
92 {"https://example.com:443", "https", "example.com", 443}, 94 {"https://example.com:443", "https", "example.com", 443},
93 {"https://example.com:444", "https", "example.com", 444}, 95 {"https://example.com:444", "https", "example.com", 444},
94 }; 96 };
95 97
96 for (const auto& test : cases) { 98 for (const auto& test : cases) {
(...skipping 20 matching lines...) Expand all
117 EXPECT_TRUE(web_origin.isUnique()); 119 EXPECT_TRUE(web_origin.isUnique());
118 120
119 url::Origin url_origin = web_origin; 121 url::Origin url_origin = web_origin;
120 EXPECT_TRUE(url_origin.unique()); 122 EXPECT_TRUE(url_origin.unique());
121 123
122 web_origin = url::Origin(GURL("")); 124 web_origin = url::Origin(GURL(""));
123 EXPECT_TRUE(web_origin.isUnique()); 125 EXPECT_TRUE(web_origin.isUnique());
124 } 126 }
125 127
126 } // namespace content 128 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | content/child/blob_storage/blob_consolidation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698