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

Side by Side Diff: chrome/utility/local_discovery/local_domain_resolver_unittest.cc

Issue 21534003: avoid char+'\xHH' as it's too easy to use values > 127 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: corresponding change in chrome unit tests Created 7 years, 4 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 | « no previous file | chrome/utility/local_discovery/service_discovery_client_unittest.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 "chrome/utility/local_discovery/service_discovery_client_impl.h" 5 #include "chrome/utility/local_discovery/service_discovery_client_impl.h"
6 #include "net/dns/mdns_client_impl.h" 6 #include "net/dns/mdns_client_impl.h"
7 #include "net/dns/mock_mdns_socket_factory.h" 7 #include "net/dns/mock_mdns_socket_factory.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using ::testing::_; 11 using ::testing::_;
12 12
13 namespace local_discovery { 13 namespace local_discovery {
14 14
15 namespace { 15 namespace {
16 16
17 const char kSamplePacketA[] = { 17 const uint8 kSamplePacketA[] = {
18 // Header 18 // Header
19 '\x00', '\x00', // ID is zeroed out 19 0x00, 0x00, // ID is zeroed out
20 '\x81', '\x80', // Standard query response, RA, no error 20 0x81, 0x80, // Standard query response, RA, no error
21 '\x00', '\x00', // No questions (for simplicity) 21 0x00, 0x00, // No questions (for simplicity)
22 '\x00', '\x01', // 1 RR (answers) 22 0x00, 0x01, // 1 RR (answers)
23 '\x00', '\x00', // 0 authority RRs 23 0x00, 0x00, // 0 authority RRs
24 '\x00', '\x00', // 0 additional RRs 24 0x00, 0x00, // 0 additional RRs
25 25
26 '\x07', 'm', 'y', 'h', 'e', 'l', 'l', 'o', 26 0x07, 'm', 'y', 'h', 'e', 'l', 'l', 'o',
27 '\x05', 'l', 'o', 'c', 'a', 'l', 27 0x05, 'l', 'o', 'c', 'a', 'l',
28 '\x00', 28 0x00,
29 '\x00', '\x01', // TYPE is A. 29 0x00, 0x01, // TYPE is A.
30 '\x00', '\x01', // CLASS is IN. 30 0x00, 0x01, // CLASS is IN.
31 '\x00', '\x00', // TTL (4 bytes) is 16 seconds. 31 0x00, 0x00, // TTL (4 bytes) is 16 seconds.
32 '\x00', '\x10', 32 0x00, 0x10,
33 '\x00', '\x04', // RDLENGTH is 4 bytes. 33 0x00, 0x04, // RDLENGTH is 4 bytes.
34 '\x01', '\x02', 34 0x01, 0x02,
35 '\x03', '\x04', 35 0x03, 0x04,
36 }; 36 };
37 37
38 const char kSamplePacketAAAA[] = { 38 const uint8 kSamplePacketAAAA[] = {
39 // Header 39 // Header
40 '\x00', '\x00', // ID is zeroed out 40 0x00, 0x00, // ID is zeroed out
41 '\x81', '\x80', // Standard query response, RA, no error 41 0x81, 0x80, // Standard query response, RA, no error
42 '\x00', '\x00', // No questions (for simplicity) 42 0x00, 0x00, // No questions (for simplicity)
43 '\x00', '\x01', // 1 RR (answers) 43 0x00, 0x01, // 1 RR (answers)
44 '\x00', '\x00', // 0 authority RRs 44 0x00, 0x00, // 0 authority RRs
45 '\x00', '\x00', // 0 additional RRs 45 0x00, 0x00, // 0 additional RRs
46 46
47 '\x07', 'm', 'y', 'h', 'e', 'l', 'l', 'o', 47 0x07, 'm', 'y', 'h', 'e', 'l', 'l', 'o',
48 '\x05', 'l', 'o', 'c', 'a', 'l', 48 0x05, 'l', 'o', 'c', 'a', 'l',
49 '\x00', 49 0x00,
50 '\x00', '\x1C', // TYPE is AAAA. 50 0x00, 0x1C, // TYPE is AAAA.
51 '\x00', '\x01', // CLASS is IN. 51 0x00, 0x01, // CLASS is IN.
52 '\x00', '\x00', // TTL (4 bytes) is 16 seconds. 52 0x00, 0x00, // TTL (4 bytes) is 16 seconds.
53 '\x00', '\x10', 53 0x00, 0x10,
54 '\x00', '\x10', // RDLENGTH is 4 bytes. 54 0x00, 0x10, // RDLENGTH is 4 bytes.
55 '\x00', '\x0A', '\x00', '\x00', 55 0x00, 0x0A, 0x00, 0x00,
56 '\x00', '\x00', '\x00', '\x00', 56 0x00, 0x00, 0x00, 0x00,
57 '\x00', '\x01', '\x00', '\x02', 57 0x00, 0x01, 0x00, 0x02,
58 '\x00', '\x03', '\x00', '\x04', 58 0x00, 0x03, 0x00, 0x04,
59 }; 59 };
60 60
61 class LocalDomainResolverTest : public testing::Test { 61 class LocalDomainResolverTest : public testing::Test {
62 public: 62 public:
63 LocalDomainResolverTest() : socket_factory_(new net::MockMDnsSocketFactory), 63 LocalDomainResolverTest() : socket_factory_(new net::MockMDnsSocketFactory),
64 mdns_client_( 64 mdns_client_(
65 scoped_ptr<net::MDnsConnection::SocketFactory>( 65 scoped_ptr<net::MDnsConnection::SocketFactory>(
66 socket_factory_)) { 66 socket_factory_)) {
67 } 67 }
68 68
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 resolver.Start(); 163 resolver.Start();
164 164
165 EXPECT_CALL(*this, AddressCallbackInternal(false, "")); 165 EXPECT_CALL(*this, AddressCallbackInternal(false, ""));
166 166
167 RunFor(base::TimeDelta::FromSeconds(4)); 167 RunFor(base::TimeDelta::FromSeconds(4));
168 } 168 }
169 169
170 } // namespace 170 } // namespace
171 171
172 } // namespace local_discovery 172 } // namespace local_discovery
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/local_discovery/service_discovery_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698