Fix a couple bugs in the settings_page_header wrt breadcrumbs.
[chromium-blink-merge.git] / android_webview / browser / aw_static_cookie_policy_unittest.cc
blobedeb315806aad72bab91b522a5d079c5cc7394c9
1 // Copyright 2014 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 "android_webview/browser/aw_cookie_access_policy.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 class GURL;
11 using android_webview::AwStaticCookiePolicy;
12 using testing::Test;
14 class AwStaticCookiePolicyTest : public Test {
15 public:
16 static const GURL kUrlFirstParty;
17 static const GURL kUrlThirdParty;
19 AwStaticCookiePolicyTest() {}
21 void expectFirstPartyAccess(const AwStaticCookiePolicy& policy,
22 bool expectedResult) {
23 EXPECT_EQ(expectedResult, policy.AllowSet(kUrlFirstParty, kUrlFirstParty));
24 EXPECT_EQ(expectedResult, policy.AllowGet(kUrlFirstParty, kUrlFirstParty));
27 void expectThirdPartyAccess(const AwStaticCookiePolicy& policy,
28 bool expectedResult) {
29 EXPECT_EQ(expectedResult, policy.AllowSet(kUrlFirstParty, kUrlThirdParty));
30 EXPECT_EQ(expectedResult, policy.AllowGet(kUrlFirstParty, kUrlThirdParty));
34 const GURL AwStaticCookiePolicyTest::kUrlFirstParty =
35 GURL("http://first.example");
36 const GURL AwStaticCookiePolicyTest::kUrlThirdParty =
37 GURL("http://third.example");
39 TEST_F(AwStaticCookiePolicyTest, BlockAllCookies) {
40 AwStaticCookiePolicy policy(false /* allow_cookies */,
41 false /* allow_third_party_cookies */);
42 expectFirstPartyAccess(policy, false);
43 expectThirdPartyAccess(policy, false);
46 TEST_F(AwStaticCookiePolicyTest, BlockAllCookiesWithThirdPartySet) {
47 AwStaticCookiePolicy policy(false /* allow_cookies */,
48 true /* allow_third_party_cookies */);
49 expectFirstPartyAccess(policy, false);
50 expectThirdPartyAccess(policy, false);
53 TEST_F(AwStaticCookiePolicyTest, FirstPartyCookiesOnly) {
54 AwStaticCookiePolicy policy(true /* allow_cookies */,
55 false /* allow_third_party_cookies */);
56 expectFirstPartyAccess(policy, true);
57 expectThirdPartyAccess(policy, false);
60 TEST_F(AwStaticCookiePolicyTest, AllowAllCookies) {
61 AwStaticCookiePolicy policy(true /* allow_cookies */,
62 true /* allow_third_party_cookies */);
63 expectFirstPartyAccess(policy, true);
64 expectThirdPartyAccess(policy, true);