OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" | 11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" |
12 #include "chrome/browser/extensions/extension_cookies_helpers.h" | 12 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "chrome/test/testing_browser_process_test.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 | 16 |
16 namespace keys = extension_cookies_api_constants; | 17 namespace keys = extension_cookies_api_constants; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 struct DomainMatchCase { | 21 struct DomainMatchCase { |
21 const char* filter; | 22 const char* filter; |
22 const char* domain; | 23 const char* domain; |
23 const bool matches; | 24 const bool matches; |
(...skipping 30 matching lines...) Expand all Loading... |
54 void set_linked_profile(OtrTestingProfile* profile) { | 55 void set_linked_profile(OtrTestingProfile* profile) { |
55 linked_profile_ = profile; | 56 linked_profile_ = profile; |
56 } | 57 } |
57 | 58 |
58 private: | 59 private: |
59 OtrTestingProfile* linked_profile_; | 60 OtrTestingProfile* linked_profile_; |
60 }; | 61 }; |
61 | 62 |
62 } // namespace | 63 } // namespace |
63 | 64 |
64 class ExtensionCookiesTest : public testing::Test { | 65 class ExtensionCookiesTest : public TestingBrowserProcessTest { |
65 }; | 66 }; |
66 | 67 |
67 TEST_F(ExtensionCookiesTest, StoreIdProfileConversion) { | 68 TEST_F(ExtensionCookiesTest, StoreIdProfileConversion) { |
68 OtrTestingProfile profile, otrProfile; | 69 OtrTestingProfile profile, otrProfile; |
69 otrProfile.set_incognito(true); | 70 otrProfile.set_incognito(true); |
70 OtrTestingProfile::LinkProfiles(&profile, &otrProfile); | 71 OtrTestingProfile::LinkProfiles(&profile, &otrProfile); |
71 | 72 |
72 EXPECT_EQ(std::string("0"), | 73 EXPECT_EQ(std::string("0"), |
73 extension_cookies_helpers::GetStoreIdFromProfile(&profile)); | 74 extension_cookies_helpers::GetStoreIdFromProfile(&profile)); |
74 EXPECT_EQ(&profile, | 75 EXPECT_EQ(&profile, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 for (size_t i = 0; i < arraysize(tests); ++i) { | 205 for (size_t i = 0; i < arraysize(tests); ++i) { |
205 details->SetString(keys::kDomainKey, std::string(tests[i].filter)); | 206 details->SetString(keys::kDomainKey, std::string(tests[i].filter)); |
206 extension_cookies_helpers::MatchFilter filter(details.get()); | 207 extension_cookies_helpers::MatchFilter filter(details.get()); |
207 net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, | 208 net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, |
208 "", "", "", base::Time(), | 209 "", "", "", base::Time(), |
209 base::Time(), base::Time(), | 210 base::Time(), base::Time(), |
210 false, false, false); | 211 false, false, false); |
211 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); | 212 EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie)); |
212 } | 213 } |
213 } | 214 } |
OLD | NEW |