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

Side by Side Diff: net/websockets/websocket_frame_parser_test.cc

Issue 1160203003: net: Remove the remaining use of GG_(U)INTn_C macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stdint.h Created 5 years, 6 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 | « net/websockets/websocket_basic_stream_test.cc ('k') | net/websockets/websocket_frame_test.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/websockets/websocket_frame_parser.h" 5 #include "net/websockets/websocket_frame_parser.h"
6 6
7 #include <stdint.h>
7 #include <algorithm> 8 #include <algorithm>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/port.h"
13 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
14 #include "net/websockets/websocket_frame.h" 14 #include "net/websockets/websocket_frame.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 20
21 const char kHello[] = "Hello, world!"; 21 const char kHello[] = "Hello, world!";
22 const uint64 kHelloLength = arraysize(kHello) - 1; 22 const uint64 kHelloLength = arraysize(kHello) - 1;
23 const char kHelloFrame[] = "\x81\x0DHello, world!"; 23 const char kHelloFrame[] = "\x81\x0DHello, world!";
24 const uint64 kHelloFrameLength = arraysize(kHelloFrame) - 1; 24 const uint64 kHelloFrameLength = arraysize(kHelloFrame) - 1;
25 const char kMaskedHelloFrame[] = 25 const char kMaskedHelloFrame[] =
26 "\x81\x8D\xDE\xAD\xBE\xEF" 26 "\x81\x8D\xDE\xAD\xBE\xEF"
27 "\x96\xC8\xD2\x83\xB1\x81\x9E\x98\xB1\xDF\xD2\x8B\xFF"; 27 "\x96\xC8\xD2\x83\xB1\x81\x9E\x98\xB1\xDF\xD2\x8B\xFF";
28 const uint64 kMaskedHelloFrameLength = arraysize(kMaskedHelloFrame) - 1; 28 const uint64 kMaskedHelloFrameLength = arraysize(kMaskedHelloFrame) - 1;
29 29
30 struct FrameHeaderTestCase { 30 struct FrameHeaderTestCase {
31 const char* frame_header; 31 const char* frame_header;
32 size_t frame_header_length; 32 size_t frame_header_length;
33 uint64 frame_length; 33 uint64 frame_length;
34 WebSocketError error_code; 34 WebSocketError error_code;
35 }; 35 };
36 36
37 const FrameHeaderTestCase kFrameHeaderTests[] = { 37 const FrameHeaderTestCase kFrameHeaderTests[] = {
38 { "\x81\x00", 2, GG_UINT64_C(0), kWebSocketNormalClosure }, 38 { "\x81\x00", 2, UINT64_C(0), kWebSocketNormalClosure },
39 { "\x81\x7D", 2, GG_UINT64_C(125), kWebSocketNormalClosure }, 39 { "\x81\x7D", 2, UINT64_C(125), kWebSocketNormalClosure },
40 { "\x81\x7E\x00\x7E", 4, GG_UINT64_C(126), kWebSocketNormalClosure }, 40 { "\x81\x7E\x00\x7E", 4, UINT64_C(126), kWebSocketNormalClosure },
41 { "\x81\x7E\xFF\xFF", 4, GG_UINT64_C(0xFFFF), kWebSocketNormalClosure }, 41 { "\x81\x7E\xFF\xFF", 4, UINT64_C(0xFFFF), kWebSocketNormalClosure },
42 { "\x81\x7F\x00\x00\x00\x00\x00\x01\x00\x00", 10, GG_UINT64_C(0x10000), 42 { "\x81\x7F\x00\x00\x00\x00\x00\x01\x00\x00", 10, UINT64_C(0x10000),
43 kWebSocketNormalClosure }, 43 kWebSocketNormalClosure },
44 { "\x81\x7F\x00\x00\x00\x00\x7F\xFF\xFF\xFF", 10, GG_UINT64_C(0x7FFFFFFF), 44 { "\x81\x7F\x00\x00\x00\x00\x7F\xFF\xFF\xFF", 10, UINT64_C(0x7FFFFFFF),
45 kWebSocketNormalClosure }, 45 kWebSocketNormalClosure },
46 { "\x81\x7F\x00\x00\x00\x00\x80\x00\x00\x00", 10, GG_UINT64_C(0x80000000), 46 { "\x81\x7F\x00\x00\x00\x00\x80\x00\x00\x00", 10, UINT64_C(0x80000000),
47 kWebSocketErrorMessageTooBig }, 47 kWebSocketErrorMessageTooBig },
48 { "\x81\x7F\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 10, 48 { "\x81\x7F\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 10,
49 GG_UINT64_C(0x7FFFFFFFFFFFFFFF), kWebSocketErrorMessageTooBig } 49 UINT64_C(0x7FFFFFFFFFFFFFFF), kWebSocketErrorMessageTooBig }
50 }; 50 };
51 const int kNumFrameHeaderTests = arraysize(kFrameHeaderTests); 51 const int kNumFrameHeaderTests = arraysize(kFrameHeaderTests);
52 52
53 TEST(WebSocketFrameParserTest, DecodeNormalFrame) { 53 TEST(WebSocketFrameParserTest, DecodeNormalFrame) {
54 WebSocketFrameParser parser; 54 WebSocketFrameParser parser;
55 55
56 ScopedVector<WebSocketFrameChunk> frames; 56 ScopedVector<WebSocketFrameChunk> frames;
57 EXPECT_TRUE(parser.Decode(kHelloFrame, kHelloFrameLength, &frames)); 57 EXPECT_TRUE(parser.Decode(kHelloFrame, kHelloFrameLength, &frames));
58 EXPECT_EQ(kWebSocketNormalClosure, parser.websocket_error()); 58 EXPECT_EQ(kWebSocketNormalClosure, parser.websocket_error());
59 ASSERT_EQ(1u, frames.size()); 59 ASSERT_EQ(1u, frames.size());
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 EXPECT_EQ(reserved3, header->reserved3); 567 EXPECT_EQ(reserved3, header->reserved3);
568 EXPECT_EQ(WebSocketFrameHeader::kOpCodeText, header->opcode); 568 EXPECT_EQ(WebSocketFrameHeader::kOpCodeText, header->opcode);
569 EXPECT_FALSE(header->masked); 569 EXPECT_FALSE(header->masked);
570 EXPECT_EQ(0u, header->payload_length); 570 EXPECT_EQ(0u, header->payload_length);
571 } 571 }
572 } 572 }
573 573
574 } // Unnamed namespace 574 } // Unnamed namespace
575 575
576 } // namespace net 576 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_basic_stream_test.cc ('k') | net/websockets/websocket_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698