Pass CreateDirectory errors up to IndexedDB.
[chromium-blink-merge.git] / net / spdy / spdy_credential_state_unittest.cc
blobb51292175601665102ba09091ef246d3eef19adc
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
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_credential_state.h"
7 #include "net/base/host_port_pair.h"
8 #include "testing/platform_test.h"
10 namespace net {
12 class SpdyCredentialStateTest : public PlatformTest {
13 public:
14 SpdyCredentialStateTest()
15 : state_(4),
16 origin1_("https://1.com"),
17 origin2_("https://2.com"),
18 origin3_("https://3.com"),
19 origin4_("https://4.com"),
20 origin5_("https://5.com"),
21 origin6_("https://6.com"),
22 origin11_("https://11.com"),
23 host1_("https://www.1.com:443") {
26 protected:
27 SpdyCredentialState state_;
28 const GURL origin1_;
29 const GURL origin2_;
30 const GURL origin3_;
31 const GURL origin4_;
32 const GURL origin5_;
33 const GURL origin6_;
34 const GURL origin11_;
35 const GURL host1_;
37 DISALLOW_COPY_AND_ASSIGN(SpdyCredentialStateTest);
40 TEST_F(SpdyCredentialStateTest, HasCredentialReturnsFalseWhenEmpty) {
41 EXPECT_FALSE(state_.HasCredential(origin1_));
42 EXPECT_FALSE(state_.HasCredential(origin2_));
43 EXPECT_FALSE(state_.HasCredential(origin3_));
46 TEST_F(SpdyCredentialStateTest, HasCredentialReturnsTrueWhenAdded) {
47 state_.SetHasCredential(origin1_);
48 EXPECT_TRUE(state_.HasCredential(origin1_));
49 EXPECT_TRUE(state_.HasCredential(host1_));
50 EXPECT_FALSE(state_.HasCredential(origin11_));
51 EXPECT_FALSE(state_.HasCredential(origin2_));
52 EXPECT_FALSE(state_.HasCredential(origin3_));
55 TEST_F(SpdyCredentialStateTest, SetCredentialAddsToEndOfList) {
56 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
57 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
58 EXPECT_EQ(3u, (state_.SetHasCredential(origin3_)));
61 TEST_F(SpdyCredentialStateTest, SetReturnsPositionIfAlreadyInList) {
62 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
63 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
64 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
65 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
68 TEST_F(SpdyCredentialStateTest, SetReplacesOldestElementWhenFull) {
69 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
70 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
71 EXPECT_EQ(3u, (state_.SetHasCredential(origin3_)));
72 EXPECT_EQ(4u, (state_.SetHasCredential(origin4_)));
73 EXPECT_EQ(1u, (state_.SetHasCredential(origin5_)));
74 EXPECT_EQ(2u, (state_.SetHasCredential(origin6_)));
75 EXPECT_EQ(3u, (state_.SetHasCredential(origin1_)));
76 EXPECT_EQ(4u, (state_.SetHasCredential(origin2_)));
79 TEST_F(SpdyCredentialStateTest, ResizeAddsEmptySpaceAtEnd) {
80 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
81 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
82 EXPECT_EQ(3u, (state_.SetHasCredential(origin3_)));
83 EXPECT_EQ(4u, (state_.SetHasCredential(origin4_)));
84 state_.Resize(6);
85 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
86 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
87 EXPECT_EQ(3u, (state_.SetHasCredential(origin3_)));
88 EXPECT_EQ(4u, (state_.SetHasCredential(origin4_)));
89 EXPECT_EQ(5u, (state_.SetHasCredential(origin5_)));
90 EXPECT_EQ(6u, (state_.SetHasCredential(origin6_)));
93 TEST_F(SpdyCredentialStateTest, ResizeTrunatesFromEnd) {
94 EXPECT_EQ(1u, (state_.SetHasCredential(origin1_)));
95 EXPECT_EQ(2u, (state_.SetHasCredential(origin2_)));
96 EXPECT_EQ(3u, (state_.SetHasCredential(origin3_)));
97 EXPECT_EQ(4u, (state_.SetHasCredential(origin4_)));
98 state_.Resize(2);
99 EXPECT_TRUE(state_.HasCredential(origin1_));
100 EXPECT_TRUE(state_.HasCredential(origin2_));
101 EXPECT_FALSE(state_.HasCredential(origin3_));
102 EXPECT_FALSE(state_.HasCredential(origin4_));
103 EXPECT_EQ(1u, (state_.SetHasCredential(origin5_)));
104 EXPECT_EQ(2u, (state_.SetHasCredential(origin6_)));
108 } // namespace net