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

Side by Side Diff: chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (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
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/browser/local_discovery/privet_local_printer_lister.h" 5 #include "chrome/browser/local_discovery/privet_local_printer_lister.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/run_loop.h" 10 #include "base/run_loop.h"
8 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
9 #include "chrome/browser/local_discovery/test_service_discovery_client.h" 12 #include "chrome/browser/local_discovery/test_service_discovery_client.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 13 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "net/url_request/test_url_fetcher_factory.h" 14 #include "net/url_request/test_url_fetcher_factory.h"
12 #include "net/url_request/url_request_test_util.h" 15 #include "net/url_request/url_request_test_util.h"
13 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 using testing::StrictMock; 19 using testing::StrictMock;
17 using testing::AtLeast; 20 using testing::AtLeast;
18 using testing::_; 21 using testing::_;
19 22
20 namespace local_discovery { 23 namespace local_discovery {
21 24
22 namespace { 25 namespace {
23 26
24 const uint8 kAnnouncePacket[] = { 27 const uint8_t kAnnouncePacket[] = {
25 // Header 28 // Header
26 0x00, 0x00, // ID is zeroed out 29 0x00, 0x00, // ID is zeroed out
27 0x80, 0x00, // Standard query response, no error 30 0x80, 0x00, // Standard query response, no error
28 0x00, 0x00, // No questions (for simplicity) 31 0x00, 0x00, // No questions (for simplicity)
29 0x00, 0x05, // 5 RR (answers) 32 0x00, 0x05, // 5 RR (answers)
30 0x00, 0x00, // 0 authority RRs 33 0x00, 0x00, // 0 authority RRs
31 0x00, 0x00, // 0 additional RRs 34 0x00, 0x00, // 0 additional RRs
32 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 35 0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_',
33 't', 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 36 't', 'c', 'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00,
34 0x00, 0x0c, // TYPE is PTR. 37 0x00, 0x0c, // TYPE is PTR.
(...skipping 27 matching lines...) Expand all
62 0x00, 0x00, // TTL (4 bytes) is 32768 second. 65 0x00, 0x00, // TTL (4 bytes) is 32768 second.
63 0x10, 0x00, 0x00, 0x04, // RDLENGTH is 4 66 0x10, 0x00, 0x00, 0x04, // RDLENGTH is 4
64 0x01, 0x02, 0x03, 0x04, // 1.2.3.4 67 0x01, 0x02, 0x03, 0x04, // 1.2.3.4
65 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 68 0x09, 'm', 'y', 'S', 'e', 'r', 'v', 'i', 'c', 'e',
66 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x1C, // Type is AAAA 69 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x1C, // Type is AAAA
67 0x00, 0x01, // CLASS is IN 70 0x00, 0x01, // CLASS is IN
68 0x00, 0x00, // TTL (4 bytes) is 32768 second. 71 0x00, 0x00, // TTL (4 bytes) is 32768 second.
69 0x10, 0x00, 0x00, 0x10, // RDLENGTH is 16 72 0x10, 0x00, 0x00, 0x10, // RDLENGTH is 16
70 0x01, 0x02, 0x03, 0x04, // 1.2.3.4 73 0x01, 0x02, 0x03, 0x04, // 1.2.3.4
71 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 74 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02,
72 0x03, 0x04, }; 75 0x03, 0x04,
76 };
73 77
74 const char kInfoIsLocalPrinter[] = "{" 78 const char kInfoIsLocalPrinter[] = "{"
75 "\"api\" : [ \"/privet/printer/submitdoc\" ]," 79 "\"api\" : [ \"/privet/printer/submitdoc\" ],"
76 "\"x-privet-token\" : \"sample\"" 80 "\"x-privet-token\" : \"sample\""
77 "}"; 81 "}";
78 82
79 const char kInfoIsNotLocalPrinter[] = "{" 83 const char kInfoIsNotLocalPrinter[] = "{"
80 "\"api\" : [ \"/privet/register\" ]," 84 "\"api\" : [ \"/privet/register\" ],"
81 "\"x-privet-token\" : \"sample\"" 85 "\"x-privet-token\" : \"sample\""
82 "}"; 86 "}";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return false; 134 return false;
131 135
132 fetcher->SetResponseString(response); 136 fetcher->SetResponseString(response);
133 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 137 fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
134 net::OK)); 138 net::OK));
135 fetcher->set_response_code(200); 139 fetcher->set_response_code(200);
136 fetcher->delegate()->OnURLFetchComplete(fetcher); 140 fetcher->delegate()->OnURLFetchComplete(fetcher);
137 return true; 141 return true;
138 } 142 }
139 143
140 void SimulateReceive(const uint8* packet, size_t size) { 144 void SimulateReceive(const uint8_t* packet, size_t size) {
141 test_service_discovery_client_->SimulateReceive(packet, size); 145 test_service_discovery_client_->SimulateReceive(packet, size);
142 base::RunLoop().RunUntilIdle(); 146 base::RunLoop().RunUntilIdle();
143 } 147 }
144 148
145 void ExpectAnyPacket() { 149 void ExpectAnyPacket() {
146 EXPECT_CALL(*test_service_discovery_client_.get(), OnSendTo(_)) 150 EXPECT_CALL(*test_service_discovery_client_.get(), OnSendTo(_))
147 .Times(AtLeast(2)); 151 .Times(AtLeast(2));
148 } 152 }
149 153
150 protected: 154 protected:
(...skipping 29 matching lines...) Expand all
180 EXPECT_CALL(delegate_, LocalPrinterChanged(true, kServiceName, false, _)); 184 EXPECT_CALL(delegate_, LocalPrinterChanged(true, kServiceName, false, _));
181 185
182 EXPECT_TRUE(SuccessfulResponseToURL( 186 EXPECT_TRUE(SuccessfulResponseToURL(
183 GURL(kPrivetInfoURL), 187 GURL(kPrivetInfoURL),
184 std::string(kInfoIsNotLocalPrinter))); 188 std::string(kInfoIsNotLocalPrinter)));
185 }; 189 };
186 190
187 } // namespace 191 } // namespace
188 192
189 } // namespace local_discovery 193 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698