Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log_unittest.cc

Issue 23983014: [Activity Log] when extension is uninstalled, delete data about it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bug in test Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/extensions/activity_log/activity_log.h" 10 #include "chrome/browser/extensions/activity_log/activity_log.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 virtual void TearDown() OVERRIDE { 58 virtual void TearDown() OVERRIDE {
59 #if defined OS_CHROMEOS 59 #if defined OS_CHROMEOS
60 test_user_manager_.reset(); 60 test_user_manager_.reset();
61 #endif 61 #endif
62 base::RunLoop().RunUntilIdle(); 62 base::RunLoop().RunUntilIdle();
63 ChromeRenderViewHostTestHarness::TearDown(); 63 ChromeRenderViewHostTestHarness::TearDown();
64 } 64 }
65 65
66 static void RetrieveActions_LogAndFetchActions( 66 static void RetrieveActions_LogAndFetchActions0(
67 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
68 ASSERT_EQ(0, static_cast<int>(i->size()));
69 }
70
71 static void RetrieveActions_LogAndFetchActions2(
67 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 72 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
68 ASSERT_EQ(2, static_cast<int>(i->size())); 73 ASSERT_EQ(2, static_cast<int>(i->size()));
69 } 74 }
70 75
71 void SetPolicy(bool log_arguments) { 76 void SetPolicy(bool log_arguments) {
72 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); 77 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
73 if (log_arguments) 78 if (log_arguments)
74 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); 79 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM);
75 else 80 else
76 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_COUNTS); 81 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_COUNTS);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 action->set_page_url(GURL("http://www.google.com")); 154 action->set_page_url(GURL("http://www.google.com"));
150 activity_log->LogAction(action); 155 activity_log->LogAction(action);
151 156
152 activity_log->GetFilteredActions( 157 activity_log->GetFilteredActions(
153 kExtensionId, 158 kExtensionId,
154 Action::ACTION_ANY, 159 Action::ACTION_ANY,
155 "", 160 "",
156 "", 161 "",
157 "", 162 "",
158 0, 163 0,
159 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); 164 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions2));
160 } 165 }
161 166
162 TEST_F(ActivityLogTest, LogPrerender) { 167 TEST_F(ActivityLogTest, LogPrerender) {
163 scoped_refptr<const Extension> extension = 168 scoped_refptr<const Extension> extension =
164 ExtensionBuilder() 169 ExtensionBuilder()
165 .SetManifest(DictionaryBuilder() 170 .SetManifest(DictionaryBuilder()
166 .Set("name", "Test extension") 171 .Set("name", "Test extension")
167 .Set("version", "1.0.0") 172 .Set("version", "1.0.0")
168 .Set("manifest_version", 2)) 173 .Set("manifest_version", 2))
169 .Build(); 174 .Build();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 .Append(DictionaryBuilder().Set("url", "http://www.google.co.uk")) 238 .Append(DictionaryBuilder().Set("url", "http://www.google.co.uk"))
234 .Build()); 239 .Build());
235 activity_log->LogAction(action); 240 activity_log->LogAction(action);
236 241
237 activity_log->GetFilteredActions( 242 activity_log->GetFilteredActions(
238 kExtensionId, 243 kExtensionId,
239 Action::ACTION_ANY, 244 Action::ACTION_ANY,
240 "", 245 "",
241 "", 246 "",
242 "", 247 "",
243 0, 248 -1,
244 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction)); 249 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction));
245 } 250 }
246 251
252 TEST_F(ActivityLogTest, UninstalledExtension) {
253 scoped_refptr<const Extension> extension =
254 ExtensionBuilder()
255 .SetManifest(DictionaryBuilder()
256 .Set("name", "Test extension")
257 .Set("version", "1.0.0")
258 .Set("manifest_version", 2))
259 .Build();
260
261 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
262 scoped_ptr<base::ListValue> args(new base::ListValue());
263 ASSERT_TRUE(GetDatabaseEnabled());
264
265 // Write some API calls
266 scoped_refptr<Action> action = new Action(extension->id(),
267 base::Time::Now(),
268 Action::ACTION_API_CALL,
269 "tabs.testMethod");
270 activity_log->LogAction(action);
271 action = new Action(extension->id(),
272 base::Time::Now(),
273 Action::ACTION_DOM_ACCESS,
274 "document.write");
275 action->set_page_url(GURL("http://www.google.com"));
276
277 activity_log->OnExtensionUninstalled(extension);
278
279 activity_log->GetFilteredActions(
280 extension->id(),
281 Action::ACTION_ANY,
282 "",
283 "",
284 "",
285 -1,
286 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions0));
287 }
288
247 } // namespace extensions 289 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_log_policy.h ('k') | chrome/browser/extensions/activity_log/counting_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698