OLD | NEW |
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/cookies/cookie_store_unittest.h" | 5 #include "net/cookies/cookie_store_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 CookieList cookies = GetAllCookies(cm.get()); | 1384 CookieList cookies = GetAllCookies(cm.get()); |
1385 size_t expected_size = 4; | 1385 size_t expected_size = 4; |
1386 EXPECT_EQ(expected_size, cookies.size()); | 1386 EXPECT_EQ(expected_size, cookies.size()); |
1387 for (CookieList::iterator it = cookies.begin(); | 1387 for (CookieList::iterator it = cookies.begin(); |
1388 it != cookies.end(); ++it) { | 1388 it != cookies.end(); ++it) { |
1389 EXPECT_NE("A1", it->Value()); | 1389 EXPECT_NE("A1", it->Value()); |
1390 EXPECT_NE("A2", it->Value()); | 1390 EXPECT_NE("A2", it->Value()); |
1391 } | 1391 } |
1392 } | 1392 } |
1393 | 1393 |
1394 TEST_F(CookieMonsterTest, InitializeFromCookieMonster) { | 1394 TEST_F(CookieMonsterTest, ImportCookiesFromCookieMonster) { |
1395 scoped_refptr<CookieMonster> cm_1(new CookieMonster(NULL, NULL)); | 1395 scoped_refptr<CookieMonster> cm_1(new CookieMonster(NULL, NULL)); |
1396 CookieOptions options; | 1396 CookieOptions options; |
1397 | 1397 |
1398 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_foo_, | 1398 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_foo_, |
1399 "A1=B; path=/foo;", | 1399 "A1=B; path=/foo;", |
1400 options)); | 1400 options)); |
1401 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_bar_, | 1401 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_bar_, |
1402 "A2=D; path=/bar;", | 1402 "A2=D; path=/bar;", |
1403 options)); | 1403 options)); |
1404 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_, | 1404 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_, |
1405 "A3=F;", | 1405 "A3=F;", |
1406 options)); | 1406 options)); |
1407 | 1407 |
1408 CookieList cookies_1 = GetAllCookies(cm_1.get()); | 1408 CookieList cookies_1 = GetAllCookies(cm_1.get()); |
1409 scoped_refptr<CookieMonster> cm_2(new CookieMonster(NULL, NULL)); | 1409 scoped_refptr<CookieMonster> cm_2(new CookieMonster(NULL, NULL)); |
1410 ASSERT_TRUE(cm_2->InitializeFrom(cookies_1)); | 1410 ASSERT_TRUE(cm_2->ImportCookies(cookies_1)); |
1411 CookieList cookies_2 = GetAllCookies(cm_2.get()); | 1411 CookieList cookies_2 = GetAllCookies(cm_2.get()); |
1412 | 1412 |
1413 size_t expected_size = 3; | 1413 size_t expected_size = 3; |
1414 EXPECT_EQ(expected_size, cookies_2.size()); | 1414 EXPECT_EQ(expected_size, cookies_2.size()); |
1415 | 1415 |
1416 CookieList::iterator it = cookies_2.begin(); | 1416 CookieList::iterator it = cookies_2.begin(); |
1417 | 1417 |
1418 ASSERT_TRUE(it != cookies_2.end()); | 1418 ASSERT_TRUE(it != cookies_2.end()); |
1419 EXPECT_EQ("A1", it->Name()); | 1419 EXPECT_EQ("A1", it->Name()); |
1420 EXPECT_EQ("/foo", it->Path()); | 1420 EXPECT_EQ("/foo", it->Path()); |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 | 2732 |
2733 // Inject our initial cookies into the mock PersistentCookieStore. | 2733 // Inject our initial cookies into the mock PersistentCookieStore. |
2734 store->SetLoadExpectation(true, initial_cookies); | 2734 store->SetLoadExpectation(true, initial_cookies); |
2735 | 2735 |
2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); | 2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); |
2737 | 2737 |
2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); | 2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); |
2739 } | 2739 } |
2740 | 2740 |
2741 } // namespace net | 2741 } // namespace net |
OLD | NEW |