[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / net / base / static_cookie_policy_unittest.cc
blob7749411addf00669fddcaad3a7c81c4dacd0b434
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
3 // found in the LICENSE file.
5 #include "net/base/net_errors.h"
6 #include "net/base/static_cookie_policy.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h"
10 namespace net {
12 class StaticCookiePolicyTest : public testing::Test {
13 public:
14 StaticCookiePolicyTest()
15 : url_google_("http://www.google.izzle"),
16 url_google_secure_("https://www.google.izzle"),
17 url_google_mail_("http://mail.google.izzle"),
18 url_google_analytics_("http://www.googleanalytics.izzle") {
20 void SetPolicyType(StaticCookiePolicy::Type type) {
21 policy_.set_type(type);
23 int CanGetCookies(const GURL& url, const GURL& first_party) {
24 return policy_.CanGetCookies(url, first_party);
26 int CanSetCookie(const GURL& url, const GURL& first_party) {
27 return policy_.CanSetCookie(url, first_party);
29 protected:
30 StaticCookiePolicy policy_;
31 GURL url_google_;
32 GURL url_google_secure_;
33 GURL url_google_mail_;
34 GURL url_google_analytics_;
37 TEST_F(StaticCookiePolicyTest, DefaultPolicyTest) {
38 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_));
39 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_));
40 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_));
41 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_analytics_));
42 EXPECT_EQ(OK, CanGetCookies(url_google_, GURL()));
44 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_));
45 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_));
46 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_));
47 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_analytics_));
48 EXPECT_EQ(OK, CanSetCookie(url_google_, GURL()));
51 TEST_F(StaticCookiePolicyTest, AllowAllCookiesTest) {
52 SetPolicyType(StaticCookiePolicy::ALLOW_ALL_COOKIES);
54 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_));
55 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_));
56 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_));
57 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_analytics_));
58 EXPECT_EQ(OK, CanGetCookies(url_google_, GURL()));
60 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_));
61 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_));
62 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_));
63 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_analytics_));
64 EXPECT_EQ(OK, CanSetCookie(url_google_, GURL()));
67 TEST_F(StaticCookiePolicyTest, BlockAllThirdPartyCookiesTest) {
68 SetPolicyType(StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES);
70 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_));
71 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_));
72 EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_));
73 EXPECT_NE(OK, CanGetCookies(url_google_, url_google_analytics_));
74 EXPECT_EQ(OK, CanGetCookies(url_google_, GURL()));
76 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_));
77 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_));
78 EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_));
79 EXPECT_NE(OK, CanSetCookie(url_google_, url_google_analytics_));
80 EXPECT_EQ(OK, CanSetCookie(url_google_, GURL()));
83 TEST_F(StaticCookiePolicyTest, BlockAllCookiesTest) {
84 SetPolicyType(StaticCookiePolicy::BLOCK_ALL_COOKIES);
86 EXPECT_NE(OK, CanGetCookies(url_google_, url_google_));
87 EXPECT_NE(OK, CanGetCookies(url_google_, url_google_secure_));
88 EXPECT_NE(OK, CanGetCookies(url_google_, url_google_mail_));
89 EXPECT_NE(OK, CanGetCookies(url_google_, url_google_analytics_));
90 EXPECT_NE(OK, CanGetCookies(url_google_, GURL()));
92 EXPECT_NE(OK, CanSetCookie(url_google_, url_google_));
93 EXPECT_NE(OK, CanSetCookie(url_google_, url_google_secure_));
94 EXPECT_NE(OK, CanSetCookie(url_google_, url_google_mail_));
95 EXPECT_NE(OK, CanSetCookie(url_google_, url_google_analytics_));
96 EXPECT_NE(OK, CanSetCookie(url_google_, GURL()));
99 } // namespace net