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

Side by Side Diff: net/quic/crypto/local_strike_register_client_test.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/quic/crypto/local_strike_register_client.h" 5 #include "net/quic/crypto/local_strike_register_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/sys_byteorder.h" 11 #include "base/sys_byteorder.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 #include "net/quic/quic_time.h" 13 #include "net/quic/quic_time.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using base::StringPiece; 16 using base::StringPiece;
17 using std::string; 17 using std::string;
18 18
19 namespace net { 19 namespace net {
20 namespace test { 20 namespace test {
21 namespace { 21 namespace {
22 22
23 class RecordResultCallback : public StrikeRegisterClient::ResultCallback { 23 class RecordResultCallback : public StrikeRegisterClient::ResultCallback {
24 public: 24 public:
25 // RecordResultCallback stores the argument to RunImpl in 25 // RecordResultCallback stores the argument to RunImpl in
26 // |*saved_value| and sets |*called| to true. The callback is self 26 // |*saved_value| and sets |*called| to true. The callback is self
27 // deleting. 27 // deleting.
28 RecordResultCallback(bool* called, bool* saved_value) 28 RecordResultCallback(bool* called, bool* saved_value)
29 : called_(called), 29 : called_(called), saved_value_(saved_value) {
30 saved_value_(saved_value) {
31 *called_ = false; 30 *called_ = false;
32 } 31 }
33 32
34 protected: 33 protected:
35 virtual void RunImpl(bool nonce_is_valid_and_unique) OVERRIDE { 34 virtual void RunImpl(bool nonce_is_valid_and_unique) OVERRIDE {
36 *called_ = true; 35 *called_ = true;
37 *saved_value_ = nonce_is_valid_and_unique; 36 *saved_value_ = nonce_is_valid_and_unique;
38 } 37 }
39 38
40 private: 39 private:
41 bool* called_; 40 bool* called_;
42 bool* saved_value_; 41 bool* saved_value_;
43 42
44 DISALLOW_COPY_AND_ASSIGN(RecordResultCallback); 43 DISALLOW_COPY_AND_ASSIGN(RecordResultCallback);
45 }; 44 };
46 45
47 const uint8 kOrbit[] = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0"; 46 const uint8 kOrbit[] = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0";
48 const uint32 kCurrentTimeExternalSecs = 12345678; 47 const uint32 kCurrentTimeExternalSecs = 12345678;
49 size_t kMaxEntries = 100; 48 size_t kMaxEntries = 100;
50 uint32 kWindowSecs = 60; 49 uint32 kWindowSecs = 60;
51 50
52 class LocalStrikeRegisterClientTest : public ::testing::Test { 51 class LocalStrikeRegisterClientTest : public ::testing::Test {
53 protected: 52 protected:
54 LocalStrikeRegisterClientTest() { 53 LocalStrikeRegisterClientTest() {}
55 }
56 54
57 virtual void SetUp() { 55 virtual void SetUp() {
58 strike_register_.reset(new LocalStrikeRegisterClient( 56 strike_register_.reset(new LocalStrikeRegisterClient(
59 kMaxEntries, kCurrentTimeExternalSecs, kWindowSecs, kOrbit, 57 kMaxEntries,
58 kCurrentTimeExternalSecs,
59 kWindowSecs,
60 kOrbit,
60 net::StrikeRegister::NO_STARTUP_PERIOD_NEEDED)); 61 net::StrikeRegister::NO_STARTUP_PERIOD_NEEDED));
61 } 62 }
62 63
63 scoped_ptr<LocalStrikeRegisterClient> strike_register_; 64 scoped_ptr<LocalStrikeRegisterClient> strike_register_;
64 }; 65 };
65 66
66 TEST_F(LocalStrikeRegisterClientTest, CheckOrbit) { 67 TEST_F(LocalStrikeRegisterClientTest, CheckOrbit) {
67 EXPECT_TRUE(strike_register_->IsKnownOrbit( 68 EXPECT_TRUE(strike_register_->IsKnownOrbit(
68 StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize))); 69 StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize)));
69 EXPECT_FALSE(strike_register_->IsKnownOrbit( 70 EXPECT_FALSE(strike_register_->IsKnownOrbit(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs), 118 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs),
118 new RecordResultCallback(&called, &is_valid)); 119 new RecordResultCallback(&called, &is_valid));
119 EXPECT_TRUE(called); 120 EXPECT_TRUE(called);
120 EXPECT_TRUE(is_valid); 121 EXPECT_TRUE(is_valid);
121 } 122 }
122 } 123 }
123 124
124 } // namespace 125 } // namespace
125 } // namespace test 126 } // namespace test
126 } // namespace net 127 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698