OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/cancelable_callback.h" | 5 #include "base/cancelable_callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 policy->RemoveURLs(urls); | 919 policy->RemoveURLs(urls); |
920 | 920 |
921 CheckReadData( | 921 CheckReadData( |
922 policy, | 922 policy, |
923 "punky", | 923 "punky", |
924 0, | 924 0, |
925 base::Bind(&CountingPolicyTest::SomeURLsRemoved)); | 925 base::Bind(&CountingPolicyTest::SomeURLsRemoved)); |
926 policy->Close(); | 926 policy->Close(); |
927 } | 927 } |
928 | 928 |
| 929 TEST_F(CountingPolicyTest, RemoveExtensionData) { |
| 930 CountingPolicy* policy = new CountingPolicy(profile_.get()); |
| 931 |
| 932 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 933 // when the test is run close to local midnight. |
| 934 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 935 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 936 base::TimeDelta::FromHours(12)); |
| 937 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); |
| 938 |
| 939 // Record some actions |
| 940 scoped_refptr<Action> action = new Action("deleteextensiondata", |
| 941 mock_clock->Now(), |
| 942 Action::ACTION_DOM_ACCESS, |
| 943 "lets"); |
| 944 action->mutable_args()->AppendString("vamoose"); |
| 945 action->set_page_title("Google"); |
| 946 action->set_arg_url(GURL("http://www.google.com")); |
| 947 policy->ProcessAction(action); |
| 948 policy->ProcessAction(action); |
| 949 policy->ProcessAction(action); |
| 950 |
| 951 scoped_refptr<Action> action2 = new Action("dontdelete", |
| 952 mock_clock->Now(), |
| 953 Action::ACTION_DOM_ACCESS, |
| 954 "lets"); |
| 955 action->mutable_args()->AppendString("vamoose"); |
| 956 action->set_page_title("Google"); |
| 957 action->set_arg_url(GURL("http://www.google.com")); |
| 958 policy->ProcessAction(action2); |
| 959 |
| 960 policy->Flush(); |
| 961 policy->RemoveExtensionData("deleteextensiondata"); |
| 962 |
| 963 CheckReadFilteredData( |
| 964 policy, |
| 965 "deleteextensiondata", |
| 966 Action::ACTION_ANY, |
| 967 "", |
| 968 "", |
| 969 "", |
| 970 -1, |
| 971 base::Bind( |
| 972 &CountingPolicyTest::RetrieveActions_FetchFilteredActions0)); |
| 973 |
| 974 CheckReadFilteredData( |
| 975 policy, |
| 976 "dontdelete", |
| 977 Action::ACTION_ANY, |
| 978 "", |
| 979 "", |
| 980 "", |
| 981 -1, |
| 982 base::Bind( |
| 983 &CountingPolicyTest::RetrieveActions_FetchFilteredActions1)); |
| 984 policy->Close(); |
| 985 } |
| 986 |
929 TEST_F(CountingPolicyTest, DeleteActions) { | 987 TEST_F(CountingPolicyTest, DeleteActions) { |
930 CountingPolicy* policy = new CountingPolicy(profile_.get()); | 988 CountingPolicy* policy = new CountingPolicy(profile_.get()); |
931 // Disable row expiration for this test by setting a time before any actions | 989 // Disable row expiration for this test by setting a time before any actions |
932 // we generate. | 990 // we generate. |
933 policy->set_retention_time(base::TimeDelta::FromDays(14)); | 991 policy->set_retention_time(base::TimeDelta::FromDays(14)); |
934 | 992 |
935 // Use a mock clock to ensure that events are not recorded on the wrong day | 993 // Use a mock clock to ensure that events are not recorded on the wrong day |
936 // when the test is run close to local midnight. Note: Ownership is passed | 994 // when the test is run close to local midnight. Note: Ownership is passed |
937 // to the policy, but we still keep a pointer locally. The policy will take | 995 // to the policy, but we still keep a pointer locally. The policy will take |
938 // care of destruction; this is safe since the policy outlives all our | 996 // care of destruction; this is safe since the policy outlives all our |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1092 |
1035 CheckReadData( | 1093 CheckReadData( |
1036 policy, | 1094 policy, |
1037 "punky", | 1095 "punky", |
1038 0, | 1096 0, |
1039 base::Bind(&CountingPolicyTest::CheckDuplicates)); | 1097 base::Bind(&CountingPolicyTest::CheckDuplicates)); |
1040 policy->Close(); | 1098 policy->Close(); |
1041 } | 1099 } |
1042 | 1100 |
1043 } // namespace extensions | 1101 } // namespace extensions |
OLD | NEW |