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

Side by Side Diff: net/quic/core/crypto/crypto_framer_test.cc

Issue 2671333004: Convert class-full-of-statics CryptoTestUtils into a namespace (Closed)
Patch Set: Created 3 years, 10 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/quic/core/crypto/channel_id_test.cc ('k') | net/quic/core/crypto/crypto_server_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 (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 "net/quic/core/crypto/crypto_framer.h" 5 #include "net/quic/core/crypto/crypto_framer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 }; 267 };
268 268
269 EXPECT_TRUE( 269 EXPECT_TRUE(
270 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); 270 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input))));
271 EXPECT_EQ(0u, framer.InputBytesRemaining()); 271 EXPECT_EQ(0u, framer.InputBytesRemaining());
272 EXPECT_EQ(0, visitor.error_count_); 272 EXPECT_EQ(0, visitor.error_count_);
273 ASSERT_EQ(1u, visitor.messages_.size()); 273 ASSERT_EQ(1u, visitor.messages_.size());
274 const CryptoHandshakeMessage& message = visitor.messages_[0]; 274 const CryptoHandshakeMessage& message = visitor.messages_[0];
275 EXPECT_EQ(0xFFAA7733, message.tag()); 275 EXPECT_EQ(0xFFAA7733, message.tag());
276 EXPECT_EQ(2u, message.tag_value_map().size()); 276 EXPECT_EQ(2u, message.tag_value_map().size());
277 EXPECT_EQ("abcdef", CryptoTestUtils::GetValueForTag(message, 0x12345678)); 277 EXPECT_EQ("abcdef", crypto_test_utils::GetValueForTag(message, 0x12345678));
278 EXPECT_EQ("ghijk", CryptoTestUtils::GetValueForTag(message, 0x12345679)); 278 EXPECT_EQ("ghijk", crypto_test_utils::GetValueForTag(message, 0x12345679));
279 } 279 }
280 280
281 TEST(CryptoFramerTest, ProcessInputWithThreeKeys) { 281 TEST(CryptoFramerTest, ProcessInputWithThreeKeys) {
282 test::TestCryptoVisitor visitor; 282 test::TestCryptoVisitor visitor;
283 CryptoFramer framer; 283 CryptoFramer framer;
284 framer.set_visitor(&visitor); 284 framer.set_visitor(&visitor);
285 285
286 unsigned char input[] = { 286 unsigned char input[] = {
287 // tag 287 // tag
288 0x33, 0x77, 0xAA, 0xFF, 288 0x33, 0x77, 0xAA, 0xFF,
(...skipping 22 matching lines...) Expand all
311 }; 311 };
312 312
313 EXPECT_TRUE( 313 EXPECT_TRUE(
314 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); 314 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input))));
315 EXPECT_EQ(0u, framer.InputBytesRemaining()); 315 EXPECT_EQ(0u, framer.InputBytesRemaining());
316 EXPECT_EQ(0, visitor.error_count_); 316 EXPECT_EQ(0, visitor.error_count_);
317 ASSERT_EQ(1u, visitor.messages_.size()); 317 ASSERT_EQ(1u, visitor.messages_.size());
318 const CryptoHandshakeMessage& message = visitor.messages_[0]; 318 const CryptoHandshakeMessage& message = visitor.messages_[0];
319 EXPECT_EQ(0xFFAA7733, message.tag()); 319 EXPECT_EQ(0xFFAA7733, message.tag());
320 EXPECT_EQ(3u, message.tag_value_map().size()); 320 EXPECT_EQ(3u, message.tag_value_map().size());
321 EXPECT_EQ("abcdef", CryptoTestUtils::GetValueForTag(message, 0x12345678)); 321 EXPECT_EQ("abcdef", crypto_test_utils::GetValueForTag(message, 0x12345678));
322 EXPECT_EQ("ghijk", CryptoTestUtils::GetValueForTag(message, 0x12345679)); 322 EXPECT_EQ("ghijk", crypto_test_utils::GetValueForTag(message, 0x12345679));
323 EXPECT_EQ("lmnopqr", CryptoTestUtils::GetValueForTag(message, 0x1234567A)); 323 EXPECT_EQ("lmnopqr", crypto_test_utils::GetValueForTag(message, 0x1234567A));
324 } 324 }
325 325
326 TEST(CryptoFramerTest, ProcessInputIncrementally) { 326 TEST(CryptoFramerTest, ProcessInputIncrementally) {
327 test::TestCryptoVisitor visitor; 327 test::TestCryptoVisitor visitor;
328 CryptoFramer framer; 328 CryptoFramer framer;
329 framer.set_visitor(&visitor); 329 framer.set_visitor(&visitor);
330 330
331 unsigned char input[] = { 331 unsigned char input[] = {
332 // tag 332 // tag
333 0x33, 0x77, 0xAA, 0xFF, 333 0x33, 0x77, 0xAA, 0xFF,
(...skipping 16 matching lines...) Expand all
350 }; 350 };
351 351
352 for (size_t i = 0; i < arraysize(input); i++) { 352 for (size_t i = 0; i < arraysize(input); i++) {
353 EXPECT_TRUE(framer.ProcessInput(StringPiece(AsChars(input) + i, 1))); 353 EXPECT_TRUE(framer.ProcessInput(StringPiece(AsChars(input) + i, 1)));
354 } 354 }
355 EXPECT_EQ(0u, framer.InputBytesRemaining()); 355 EXPECT_EQ(0u, framer.InputBytesRemaining());
356 ASSERT_EQ(1u, visitor.messages_.size()); 356 ASSERT_EQ(1u, visitor.messages_.size());
357 const CryptoHandshakeMessage& message = visitor.messages_[0]; 357 const CryptoHandshakeMessage& message = visitor.messages_[0];
358 EXPECT_EQ(0xFFAA7733, message.tag()); 358 EXPECT_EQ(0xFFAA7733, message.tag());
359 EXPECT_EQ(2u, message.tag_value_map().size()); 359 EXPECT_EQ(2u, message.tag_value_map().size());
360 EXPECT_EQ("abcdef", CryptoTestUtils::GetValueForTag(message, 0x12345678)); 360 EXPECT_EQ("abcdef", crypto_test_utils::GetValueForTag(message, 0x12345678));
361 EXPECT_EQ("ghijk", CryptoTestUtils::GetValueForTag(message, 0x12345679)); 361 EXPECT_EQ("ghijk", crypto_test_utils::GetValueForTag(message, 0x12345679));
362 } 362 }
363 363
364 TEST(CryptoFramerTest, ProcessInputTagsOutOfOrder) { 364 TEST(CryptoFramerTest, ProcessInputTagsOutOfOrder) {
365 test::TestCryptoVisitor visitor; 365 test::TestCryptoVisitor visitor;
366 CryptoFramer framer; 366 CryptoFramer framer;
367 framer.set_visitor(&visitor); 367 framer.set_visitor(&visitor);
368 368
369 unsigned char input[] = { 369 unsigned char input[] = {
370 // tag 370 // tag
371 0x33, 0x77, 0xAA, 0xFF, 371 0x33, 0x77, 0xAA, 0xFF,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 }; 460 };
461 461
462 EXPECT_TRUE( 462 EXPECT_TRUE(
463 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input)))); 463 framer.ProcessInput(StringPiece(AsChars(input), arraysize(input))));
464 EXPECT_EQ(0, visitor.error_count_); 464 EXPECT_EQ(0, visitor.error_count_);
465 } 465 }
466 466
467 } // namespace test 467 } // namespace test
468 468
469 } // namespace net 469 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/channel_id_test.cc ('k') | net/quic/core/crypto/crypto_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698