OLD | NEW |
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.h" | 7 #include "base/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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 activity_log->GetActions( | 197 activity_log->GetActions( |
198 kExtensionId, | 198 kExtensionId, |
199 0, | 199 0, |
200 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); | 200 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); |
201 } | 201 } |
202 | 202 |
203 TEST_F(ActivityLogTest, LogWithoutArguments) { | 203 TEST_F(ActivityLogTest, LogWithoutArguments) { |
204 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 204 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
205 activity_log->SetArgumentLoggingForTesting(false); | 205 activity_log->SetArgumentLoggingForTesting(false); |
206 ASSERT_TRUE(activity_log->IsLogEnabled()); | 206 ASSERT_TRUE(activity_log->IsLogEnabled()); |
207 | 207 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); |
208 scoped_ptr<ListValue> args(new ListValue()); | 208 scoped_ptr<ListValue> args(new ListValue()); |
209 args->Set(0, new base::StringValue("hello")); | 209 args->Set(0, new base::StringValue("hello")); |
210 args->Set(1, new base::StringValue("world")); | 210 args->Set(1, new base::StringValue("world")); |
211 activity_log->LogAPIAction( | 211 activity_log->LogAPIAction( |
212 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); | 212 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); |
213 activity_log->GetActions( | 213 activity_log->GetActions( |
214 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Missing)); | 214 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Missing)); |
215 } | 215 } |
216 | 216 |
217 TEST_F(ActivityLogTest, LogWithArguments) { | 217 TEST_F(ActivityLogTest, LogWithArguments) { |
218 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 218 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
| 219 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
219 ASSERT_TRUE(activity_log->IsLogEnabled()); | 220 ASSERT_TRUE(activity_log->IsLogEnabled()); |
220 | 221 |
221 scoped_ptr<ListValue> args(new ListValue()); | 222 scoped_ptr<ListValue> args(new ListValue()); |
222 args->Set(0, new base::StringValue("hello")); | 223 args->Set(0, new base::StringValue("hello")); |
223 args->Set(1, new base::StringValue("world")); | 224 args->Set(1, new base::StringValue("world")); |
224 activity_log->LogAPIAction(kExtensionId, | 225 activity_log->LogAPIAction(kExtensionId, |
225 std::string("extension.connect"), | 226 std::string("extension.connect"), |
226 args.get(), | 227 args.get(), |
227 std::string()); | 228 std::string()); |
228 activity_log->GetActions( | 229 activity_log->GetActions( |
229 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); | 230 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); |
230 } | 231 } |
231 | 232 |
232 TEST_F(RenderViewActivityLogTest, LogPrerender) { | 233 TEST_F(RenderViewActivityLogTest, LogPrerender) { |
233 scoped_refptr<const Extension> extension = | 234 scoped_refptr<const Extension> extension = |
234 ExtensionBuilder() | 235 ExtensionBuilder() |
235 .SetManifest(DictionaryBuilder() | 236 .SetManifest(DictionaryBuilder() |
236 .Set("name", "Test extension") | 237 .Set("name", "Test extension") |
237 .Set("version", "1.0.0") | 238 .Set("version", "1.0.0") |
238 .Set("manifest_version", 2)) | 239 .Set("manifest_version", 2)) |
239 .Build(); | 240 .Build(); |
240 extension_service_->AddExtension(extension.get()); | 241 extension_service_->AddExtension(extension.get()); |
241 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); | 242 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); |
| 243 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
242 ASSERT_TRUE(activity_log->IsLogEnabled()); | 244 ASSERT_TRUE(activity_log->IsLogEnabled()); |
243 GURL url("http://www.google.com"); | 245 GURL url("http://www.google.com"); |
244 | 246 |
245 prerender::PrerenderManager* prerender_manager = | 247 prerender::PrerenderManager* prerender_manager = |
246 prerender::PrerenderManagerFactory::GetForProfile( | 248 prerender::PrerenderManagerFactory::GetForProfile( |
247 Profile::FromBrowserContext(profile())); | 249 Profile::FromBrowserContext(profile())); |
248 | 250 |
249 const gfx::Size kSize(640, 480); | 251 const gfx::Size kSize(640, 480); |
250 scoped_ptr<prerender::PrerenderHandle> prerender_handle( | 252 scoped_ptr<prerender::PrerenderHandle> prerender_handle( |
251 prerender_manager->AddPrerenderFromLocalPredictor( | 253 prerender_manager->AddPrerenderFromLocalPredictor( |
(...skipping 15 matching lines...) Expand all Loading... |
267 | 269 |
268 activity_log->GetActions( | 270 activity_log->GetActions( |
269 extension->id(), 0, base::Bind( | 271 extension->id(), 0, base::Bind( |
270 RenderViewActivityLogTest::Arguments_Prerender)); | 272 RenderViewActivityLogTest::Arguments_Prerender)); |
271 | 273 |
272 prerender_manager->CancelAllPrerenders(); | 274 prerender_manager->CancelAllPrerenders(); |
273 } | 275 } |
274 | 276 |
275 } // namespace extensions | 277 } // namespace extensions |
276 | 278 |
OLD | NEW |