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

Side by Side Diff: net/cookies/cookie_monster_unittest.cc

Issue 1746303002: Replace std::string::find with base::StartsWith when comparing cookie paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove new test case Created 4 years, 9 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 (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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 // Chrome's current implementation deviates from the spec so capturing this to 1560 // Chrome's current implementation deviates from the spec so capturing this to
1561 // avoid any inadvertent changes to this behavior. 1561 // avoid any inadvertent changes to this behavior.
1562 EXPECT_EQ("A3", cookies[0].Value()); 1562 EXPECT_EQ("A3", cookies[0].Value());
1563 EXPECT_EQ("B3", cookies[1].Value()); 1563 EXPECT_EQ("B3", cookies[1].Value());
1564 EXPECT_EQ("B2", cookies[2].Value()); 1564 EXPECT_EQ("B2", cookies[2].Value());
1565 EXPECT_EQ("A2", cookies[3].Value()); 1565 EXPECT_EQ("A2", cookies[3].Value());
1566 EXPECT_EQ("B1", cookies[4].Value()); 1566 EXPECT_EQ("B1", cookies[4].Value());
1567 EXPECT_EQ("A1", cookies[5].Value()); 1567 EXPECT_EQ("A1", cookies[5].Value());
1568 } 1568 }
1569 1569
1570 TEST_F(CookieMonsterTest, DeleteCookieByName) {
1571 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1572
1573 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=A1; path=/"));
1574 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=A2; path=/foo"));
1575 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=A3; path=/bar"));
1576 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "B=B1; path=/"));
1577 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "B=B2; path=/foo"));
1578 EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "B=B3; path=/bar"));
1579
1580 DeleteCookie(cm.get(), http_www_google_.AppendPath("foo/bar"), "A");
1581
1582 CookieList cookies = GetAllCookies(cm.get());
1583 size_t expected_size = 4;
1584 EXPECT_EQ(expected_size, cookies.size());
1585 for (CookieList::iterator it = cookies.begin(); it != cookies.end(); ++it) {
1586 EXPECT_NE("A1", it->Value());
1587 EXPECT_NE("A2", it->Value());
1588 }
1589 }
1590
1591 // Tests importing from a persistent cookie store that contains duplicate 1570 // Tests importing from a persistent cookie store that contains duplicate
1592 // equivalent cookies. This situation should be handled by removing the 1571 // equivalent cookies. This situation should be handled by removing the
1593 // duplicate cookie (both from the in-memory cache, and from the backing store). 1572 // duplicate cookie (both from the in-memory cache, and from the backing store).
1594 // 1573 //
1595 // This is a regression test for: http://crbug.com/17855. 1574 // This is a regression test for: http://crbug.com/17855.
1596 TEST_F(CookieMonsterTest, DontImportDuplicateCookies) { 1575 TEST_F(CookieMonsterTest, DontImportDuplicateCookies) {
1597 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); 1576 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
1598 1577
1599 // We will fill some initial cookies into the PersistentCookieStore, 1578 // We will fill some initial cookies into the PersistentCookieStore,
1600 // to simulate a database with 4 duplicates. Note that we need to 1579 // to simulate a database with 4 duplicates. Note that we need to
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 monster()->AddCallbackForCookie( 3140 monster()->AddCallbackForCookie(
3162 test_url_, "abc", 3141 test_url_, "abc",
3163 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); 3142 base::Bind(&RecordCookieChanges, &cookies1, nullptr)));
3164 SetCookie(monster(), test_url_, "abc=def"); 3143 SetCookie(monster(), test_url_, "abc=def");
3165 base::MessageLoop::current()->RunUntilIdle(); 3144 base::MessageLoop::current()->RunUntilIdle();
3166 EXPECT_EQ(1U, cookies0.size()); 3145 EXPECT_EQ(1U, cookies0.size());
3167 EXPECT_EQ(1U, cookies0.size()); 3146 EXPECT_EQ(1U, cookies0.size());
3168 } 3147 }
3169 3148
3170 } // namespace net 3149 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698