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 // Tests common functionality used by the Chrome Extensions Cookies API | 5 // Tests common functionality used by the Chrome Extensions Cookies API |
6 // implementation. | 6 // implementation. |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 class ExtensionCookiesTest : public testing::Test { | 42 class ExtensionCookiesTest : public testing::Test { |
43 private: | 43 private: |
44 content::TestBrowserThreadBundle thread_bundle_; | 44 content::TestBrowserThreadBundle thread_bundle_; |
45 }; | 45 }; |
46 | 46 |
47 TEST_F(ExtensionCookiesTest, StoreIdProfileConversion) { | 47 TEST_F(ExtensionCookiesTest, StoreIdProfileConversion) { |
48 TestingProfile::Builder profile_builder; | 48 TestingProfile::Builder profile_builder; |
49 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 49 std::unique_ptr<TestingProfile> profile = profile_builder.Build(); |
50 // Trigger early creation of off-the-record profile. | 50 // Trigger early creation of off-the-record profile. |
51 EXPECT_TRUE(profile->GetOffTheRecordProfile()); | 51 EXPECT_TRUE(profile->GetOffTheRecordProfile()); |
52 | 52 |
53 EXPECT_EQ(std::string("0"), | 53 EXPECT_EQ(std::string("0"), |
54 cookies_helpers::GetStoreIdFromProfile(profile.get())); | 54 cookies_helpers::GetStoreIdFromProfile(profile.get())); |
55 EXPECT_EQ(profile.get(), | 55 EXPECT_EQ(profile.get(), |
56 cookies_helpers::ChooseProfileFromStoreId( | 56 cookies_helpers::ChooseProfileFromStoreId( |
57 "0", profile.get(), true)); | 57 "0", profile.get(), true)); |
58 EXPECT_EQ(profile.get(), | 58 EXPECT_EQ(profile.get(), |
59 cookies_helpers::ChooseProfileFromStoreId( | 59 cookies_helpers::ChooseProfileFromStoreId( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 { ".bar.com", "baz.foo.bar.com", true }, | 160 { ".bar.com", "baz.foo.bar.com", true }, |
161 { "foo.bar.com", ".bar.com", false } | 161 { "foo.bar.com", ".bar.com", false } |
162 }; | 162 }; |
163 | 163 |
164 for (size_t i = 0; i < arraysize(tests); ++i) { | 164 for (size_t i = 0; i < arraysize(tests); ++i) { |
165 // Build up the Params struct. | 165 // Build up the Params struct. |
166 base::ListValue args; | 166 base::ListValue args; |
167 base::DictionaryValue* dict = new base::DictionaryValue(); | 167 base::DictionaryValue* dict = new base::DictionaryValue(); |
168 dict->SetString(keys::kDomainKey, std::string(tests[i].filter)); | 168 dict->SetString(keys::kDomainKey, std::string(tests[i].filter)); |
169 args.Set(0, dict); | 169 args.Set(0, dict); |
170 scoped_ptr<GetAll::Params> params(GetAll::Params::Create(args)); | 170 std::unique_ptr<GetAll::Params> params(GetAll::Params::Create(args)); |
171 | 171 |
172 cookies_helpers::MatchFilter filter(¶ms->details); | 172 cookies_helpers::MatchFilter filter(¶ms->details); |
173 net::CanonicalCookie cookie( | 173 net::CanonicalCookie cookie( |
174 GURL(), std::string(), std::string(), tests[i].domain, std::string(), | 174 GURL(), std::string(), std::string(), tests[i].domain, std::string(), |
175 base::Time(), base::Time(), base::Time(), false, false, | 175 base::Time(), base::Time(), base::Time(), false, false, |
176 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); | 176 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); |
177 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); | 177 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 TEST_F(ExtensionCookiesTest, DecodeUTF8WithErrorHandling) { | 181 TEST_F(ExtensionCookiesTest, DecodeUTF8WithErrorHandling) { |
182 net::CanonicalCookie canonical_cookie( | 182 net::CanonicalCookie canonical_cookie( |
183 GURL(), std::string(), "011Q255bNX_1!yd\203e+", "test.com", "/path\203", | 183 GURL(), std::string(), "011Q255bNX_1!yd\203e+", "test.com", "/path\203", |
184 base::Time(), base::Time(), base::Time(), false, false, | 184 base::Time(), base::Time(), base::Time(), false, false, |
185 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); | 185 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); |
186 Cookie cookie = | 186 Cookie cookie = |
187 cookies_helpers::CreateCookie(canonical_cookie, "some cookie store"); | 187 cookies_helpers::CreateCookie(canonical_cookie, "some cookie store"); |
188 EXPECT_EQ(std::string("011Q255bNX_1!yd\xEF\xBF\xBD" | 188 EXPECT_EQ(std::string("011Q255bNX_1!yd\xEF\xBF\xBD" |
189 "e+"), | 189 "e+"), |
190 cookie.value); | 190 cookie.value); |
191 EXPECT_EQ(std::string(), cookie.path); | 191 EXPECT_EQ(std::string(), cookie.path); |
192 } | 192 } |
193 | 193 |
194 } // namespace extensions | 194 } // namespace extensions |
OLD | NEW |