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

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

Issue 23600024: Revert 222242 "[Activity Log] when extension is uninstalled, del..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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_LogAndFetchActions0( 66 static void RetrieveActions_LogAndFetchActions(
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(
72 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 67 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
73 ASSERT_EQ(2, static_cast<int>(i->size())); 68 ASSERT_EQ(2, static_cast<int>(i->size()));
74 } 69 }
75 70
76 void SetPolicy(bool log_arguments) { 71 void SetPolicy(bool log_arguments) {
77 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); 72 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
78 if (log_arguments) 73 if (log_arguments)
79 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); 74 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM);
80 else 75 else
81 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_COUNTS); 76 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_COUNTS);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 action->set_page_url(GURL("http://www.google.com")); 149 action->set_page_url(GURL("http://www.google.com"));
155 activity_log->LogAction(action); 150 activity_log->LogAction(action);
156 151
157 activity_log->GetFilteredActions( 152 activity_log->GetFilteredActions(
158 kExtensionId, 153 kExtensionId,
159 Action::ACTION_ANY, 154 Action::ACTION_ANY,
160 "", 155 "",
161 "", 156 "",
162 "", 157 "",
163 0, 158 0,
164 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions2)); 159 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions));
165 } 160 }
166 161
167 TEST_F(ActivityLogTest, LogPrerender) { 162 TEST_F(ActivityLogTest, LogPrerender) {
168 scoped_refptr<const Extension> extension = 163 scoped_refptr<const Extension> extension =
169 ExtensionBuilder() 164 ExtensionBuilder()
170 .SetManifest(DictionaryBuilder() 165 .SetManifest(DictionaryBuilder()
171 .Set("name", "Test extension") 166 .Set("name", "Test extension")
172 .Set("version", "1.0.0") 167 .Set("version", "1.0.0")
173 .Set("manifest_version", 2)) 168 .Set("manifest_version", 2))
174 .Build(); 169 .Build();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 activity_log->GetFilteredActions( 237 activity_log->GetFilteredActions(
243 kExtensionId, 238 kExtensionId,
244 Action::ACTION_ANY, 239 Action::ACTION_ANY,
245 "", 240 "",
246 "", 241 "",
247 "", 242 "",
248 0, 243 0,
249 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction)); 244 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction));
250 } 245 }
251 246
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 0,
286 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions0));
287 }
288
289 } // namespace extensions 247 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698