| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 |
| 7 #include "chrome/browser/net/clear_on_exit_policy.h" |
| 8 #include "googleurl/src/gurl.h" |
| 9 #include "webkit/quota/mock_special_storage_policy.h" |
| 10 |
| 11 |
| 12 TEST(ClearOnExitPolicyTest, HasClearOnExitOrigins) { |
| 13 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
| 14 new quota::MockSpecialStoragePolicy; |
| 15 scoped_refptr<ClearOnExitPolicy> policy = |
| 16 new ClearOnExitPolicy(storage_policy.get()); |
| 17 |
| 18 EXPECT_FALSE(policy->HasClearOnExitOrigins()); |
| 19 |
| 20 storage_policy->AddSessionOnly(GURL("http://test.com/")); |
| 21 EXPECT_TRUE(policy->HasClearOnExitOrigins()); |
| 22 } |
| 23 |
| 24 TEST(ClearOnExitPolicyTest, ShouldClearOriginOnExit) { |
| 25 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
| 26 new quota::MockSpecialStoragePolicy; |
| 27 storage_policy->AddSessionOnly(GURL("http://session.com/")); |
| 28 storage_policy->AddSessionOnly(GURL("https://secure.com/")); |
| 29 storage_policy->AddSessionOnly(GURL("http://protected.com/")); |
| 30 storage_policy->AddProtected(GURL("http://protected.com/")); |
| 31 |
| 32 scoped_refptr<ClearOnExitPolicy> policy = |
| 33 new ClearOnExitPolicy(storage_policy.get()); |
| 34 |
| 35 EXPECT_TRUE(policy->ShouldClearOriginOnExit("session.com", false)); |
| 36 EXPECT_FALSE(policy->ShouldClearOriginOnExit("session.com", true)); |
| 37 |
| 38 EXPECT_FALSE(policy->ShouldClearOriginOnExit("secure.com", false)); |
| 39 EXPECT_TRUE(policy->ShouldClearOriginOnExit("secure.com", true)); |
| 40 |
| 41 EXPECT_FALSE(policy->ShouldClearOriginOnExit("protected.com", false)); |
| 42 EXPECT_FALSE(policy->ShouldClearOriginOnExit("protected.com", true)); |
| 43 |
| 44 EXPECT_FALSE(policy->ShouldClearOriginOnExit("other.com", false)); |
| 45 EXPECT_FALSE(policy->ShouldClearOriginOnExit("other.com", true)); |
| 46 } |
| OLD | NEW |