 Chromium Code Reviews
 Chromium Code Reviews Issue 15573003:
  New architecture of the activity logging: Policies for summarization (and compression)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 15573003:
  New architecture of the activity logging: Policies for summarization (and compression)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/browser/extensions/activity_log/stream_noargs_ui_policy_unittest.cc | 
| diff --git a/chrome/browser/extensions/activity_log/activity_log_unittest.cc b/chrome/browser/extensions/activity_log/stream_noargs_ui_policy_unittest.cc | 
| similarity index 56% | 
| copy from chrome/browser/extensions/activity_log/activity_log_unittest.cc | 
| copy to chrome/browser/extensions/activity_log/stream_noargs_ui_policy_unittest.cc | 
| index 10eb34f07b5f47d3bf541b85275dfc4037e51ae7..2670f4e6bcf2059513f0d027893d9a4090941758 100644 | 
| --- a/chrome/browser/extensions/activity_log/activity_log_unittest.cc | 
| +++ b/chrome/browser/extensions/activity_log/stream_noargs_ui_policy_unittest.cc | 
| @@ -1,4 +1,4 @@ | 
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| +// Copyright $YEAR The Chromium Authors. All rights reserved. | 
| 
Matt Perry
2013/05/30 18:55:32
?
 
dbabic
2013/05/30 21:51:25
Sorry, I took http://www.chromium.org/developers/c
 | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
| @@ -6,6 +6,7 @@ | 
| #include "base/memory/scoped_ptr.h" | 
| #include "base/synchronization/waitable_event.h" | 
| #include "chrome/browser/extensions/activity_log/activity_log.h" | 
| +#include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h" | 
| #include "chrome/browser/extensions/extension_service.h" | 
| #include "chrome/browser/extensions/test_extension_system.h" | 
| #include "chrome/common/chrome_constants.h" | 
| @@ -26,9 +27,9 @@ | 
| namespace extensions { | 
| -class ActivityLogTest : public ChromeRenderViewHostTestHarness { | 
| +class StreamWithoutArgsUIPolicyTest : public ChromeRenderViewHostTestHarness { | 
| public: | 
| - ActivityLogTest() | 
| + StreamWithoutArgsUIPolicyTest() | 
| : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 
| db_thread_(BrowserThread::DB, base::MessageLoop::current()), | 
| file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} | 
| @@ -42,16 +43,12 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { | 
| ExtensionSystem::Get(profile_))->CreateExtensionService( | 
| &command_line, base::FilePath(), false); | 
| CommandLine::ForCurrentProcess()->AppendSwitch( | 
| - switches::kEnableExtensionActivityLogging); | 
| - CommandLine::ForCurrentProcess()->AppendSwitch( | 
| switches::kEnableExtensionActivityLogTesting); | 
| - ActivityLog::RecomputeLoggingIsEnabled(); | 
| } | 
| - virtual ~ActivityLogTest() { | 
| - base::MessageLoop::current()->PostTask(FROM_HERE, | 
| - base::MessageLoop::QuitClosure()); | 
| - base::MessageLoop::current()->Run(); | 
| + virtual ~StreamWithoutArgsUIPolicyTest() { | 
| + MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 
| + MessageLoop::current()->Run(); | 
| } | 
| static void RetrieveActions_LogAndFetchActions( | 
| @@ -67,14 +64,6 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { | 
| ASSERT_EQ(noargs, last->PrintForDebug()); | 
| } | 
| - static void Arguments_Present( | 
| - scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 
| - scoped_refptr<Action> last = i->front(); | 
| - std::string args = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: " | 
| - "CALL, API: extension.connect, ARGS: \"hello\", \"world\""; | 
| - ASSERT_EQ(args, last->PrintForDebug()); | 
| - } | 
| - | 
| protected: | 
| ExtensionService* extension_service_; | 
| Profile* profile_; | 
| @@ -91,12 +80,9 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { | 
| #endif | 
| }; | 
| -TEST_F(ActivityLogTest, Enabled) { | 
| - ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 
| -} | 
| - | 
| -TEST_F(ActivityLogTest, Construct) { | 
| - ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 
| +TEST_F(StreamWithoutArgsUIPolicyTest, Construct) { | 
| + ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_, | 
| + BrowserThread::UI); | 
| scoped_refptr<const Extension> extension = | 
| ExtensionBuilder() | 
| .SetManifest(DictionaryBuilder() | 
| @@ -106,13 +92,14 @@ TEST_F(ActivityLogTest, Construct) { | 
| .Build(); | 
| extension_service_->AddExtension(extension); | 
| scoped_ptr<ListValue> args(new ListValue()); | 
| - ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 
| - activity_log->LogAPIAction( | 
| - extension, std::string("tabs.testMethod"), args.get(), std::string()); | 
| + policy->ProcessAction(ActivityLogPolicy::ACTION_API, *extension.get(), | 
| + std::string("tabs.testMethod"), NULL, args.get(), NULL); | 
| + delete policy; | 
| } | 
| -TEST_F(ActivityLogTest, LogAndFetchActions) { | 
| - ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 
| +TEST_F(StreamWithoutArgsUIPolicyTest, LogAndFetchActions) { | 
| + ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_, | 
| + BrowserThread::UI); | 
| scoped_refptr<const Extension> extension = | 
| ExtensionBuilder() | 
| .SetManifest(DictionaryBuilder() | 
| @@ -122,26 +109,23 @@ TEST_F(ActivityLogTest, LogAndFetchActions) { | 
| .Build(); | 
| extension_service_->AddExtension(extension); | 
| scoped_ptr<ListValue> args(new ListValue()); | 
| - ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 
| + GURL* gurl = new GURL("http://www.google.com"); | 
| // Write some API calls | 
| - activity_log->LogAPIAction( | 
| - extension, std::string("tabs.testMethod"), args.get(), std::string()); | 
| - activity_log->LogDOMAction(extension, | 
| - GURL("http://www.google.com"), | 
| - string16(), | 
| - std::string("document.write"), | 
| - args.get(), | 
| - std::string("extra")); | 
| - activity_log->GetActions( | 
| - extension->id(), | 
| - 0, | 
| - base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); | 
| + policy->ProcessAction(ActivityLogPolicy::ACTION_API, *extension.get(), | 
| + std::string("tabs.testMethod"), NULL, args.get(), NULL); | 
| + policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, | 
| + *extension.get(), std::string("document.write"), gurl, args.get(), NULL); | 
| + policy->ReadData(extension->id(), 0, | 
| + base::Bind( | 
| + StreamWithoutArgsUIPolicyTest::RetrieveActions_LogAndFetchActions)); | 
| + delete policy; | 
| + delete gurl; | 
| } | 
| -TEST_F(ActivityLogTest, LogWithoutArguments) { | 
| - ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 
| - activity_log->SetArgumentLoggingForTesting(false); | 
| +TEST_F(StreamWithoutArgsUIPolicyTest, LogWithoutArguments) { | 
| + ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_, | 
| + BrowserThread::UI); | 
| scoped_refptr<const Extension> extension = | 
| ExtensionBuilder() | 
| .SetManifest(DictionaryBuilder() | 
| @@ -150,37 +134,14 @@ TEST_F(ActivityLogTest, LogWithoutArguments) { | 
| .Set("manifest_version", 2)) | 
| .Build(); | 
| extension_service_->AddExtension(extension); | 
| - ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 
| - | 
| scoped_ptr<ListValue> args(new ListValue()); | 
| args->Set(0, new base::StringValue("hello")); | 
| args->Set(1, new base::StringValue("world")); | 
| - activity_log->LogAPIAction( | 
| - extension, std::string("tabs.testMethod"), args.get(), std::string()); | 
| - activity_log->GetActions( | 
| - extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Missing)); | 
| + policy->ProcessAction(ActivityLogPolicy::ACTION_API, *extension.get(), | 
| + std::string("tabs.testMethod"), NULL, args.get(), NULL); | 
| + policy->ReadData(extension->id(), 0, | 
| + base::Bind(StreamWithoutArgsUIPolicyTest::Arguments_Missing)); | 
| + delete policy; | 
| } | 
| -TEST_F(ActivityLogTest, LogWithArguments) { | 
| - ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 
| - scoped_refptr<const Extension> extension = | 
| - ExtensionBuilder() | 
| - .SetManifest(DictionaryBuilder() | 
| - .Set("name", "Test extension") | 
| - .Set("version", "1.0.0") | 
| - .Set("manifest_version", 2)) | 
| - .Build(); | 
| - extension_service_->AddExtension(extension); | 
| - ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 
| - | 
| - scoped_ptr<ListValue> args(new ListValue()); | 
| - args->Set(0, new base::StringValue("hello")); | 
| - args->Set(1, new base::StringValue("world")); | 
| - activity_log->LogAPIAction( | 
| - extension, std::string("extension.connect"), args.get(), std::string()); | 
| - activity_log->GetActions( | 
| - extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Present)); | 
| -} | 
| - | 
| -} // namespace extensions | 
| - | 
| +} // End of namespace extensions |