Index: chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc |
diff --git a/chrome/browser/extensions/activity_log/activity_log_unittest.cc b/chrome/browser/extensions/activity_log/fullstream_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/fullstream_ui_policy_unittest.cc |
index 10eb34f07b5f47d3bf541b85275dfc4037e51ae7..5b3ee9aaaf521060cfde67bb55b81fc8c43fa815 100644 |
--- a/chrome/browser/extensions/activity_log/activity_log_unittest.cc |
+++ b/chrome/browser/extensions/activity_log/fullstream_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. |
// 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/fullstream_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,13 +27,14 @@ |
namespace extensions { |
-class ActivityLogTest : public ChromeRenderViewHostTestHarness { |
+class FullStreamUIPolicyTest : public ChromeRenderViewHostTestHarness { |
public: |
- ActivityLogTest() |
+ FullStreamUIPolicyTest() |
: ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
db_thread_(BrowserThread::DB, base::MessageLoop::current()), |
file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} |
+ |
virtual void SetUp() OVERRIDE { |
ChromeRenderViewHostTestHarness::SetUp(); |
CommandLine command_line(CommandLine::NO_PROGRAM); |
@@ -42,16 +44,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 ~FullStreamUIPolicyTest() { |
+ MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
+ MessageLoop::current()->Run(); |
} |
static void RetrieveActions_LogAndFetchActions( |
@@ -59,14 +57,6 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness { |
ASSERT_EQ(2, static_cast<int>(i->size())); |
} |
- static void Arguments_Missing( |
- scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
- scoped_refptr<Action> last = i->front(); |
- std::string noargs = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: " |
- "CALL, API: tabs.testMethod, ARGS: "; |
- ASSERT_EQ(noargs, last->PrintForDebug()); |
- } |
- |
static void Arguments_Present( |
scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
scoped_refptr<Action> last = i->front(); |
@@ -91,12 +81,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(FullStreamUIPolicyTest, Construct) { |
+ ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_, |
+ BrowserThread::UI); |
felt
2013/05/30 03:36:34
nit: indent to match profile_, or put profile_ on
dbabic
2013/05/30 16:52:00
Done.
|
scoped_refptr<const Extension> extension = |
ExtensionBuilder() |
.SetManifest(DictionaryBuilder() |
@@ -106,13 +93,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(FullStreamUIPolicyTest, LogAndFetchActions) { |
+ ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_, |
+ BrowserThread::UI); |
scoped_refptr<const Extension> extension = |
ExtensionBuilder() |
.SetManifest(DictionaryBuilder() |
@@ -122,47 +110,22 @@ 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)); |
-} |
- |
-TEST_F(ActivityLogTest, LogWithoutArguments) { |
- ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
- activity_log->SetArgumentLoggingForTesting(false); |
- 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("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->ProcessAction(ActivityLogPolicy::ACTION_DOM, |
+ *extension.get(), std::string("document.write"), gurl, args.get(), NULL); |
+ policy->ReadData(extension->id(), 0, |
+ base::Bind(FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); |
+ delete policy; |
+ delete gurl; |
} |
-TEST_F(ActivityLogTest, LogWithArguments) { |
- ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
+TEST_F(FullStreamUIPolicyTest, LogWithArguments) { |
+ ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_, |
+ BrowserThread::UI); |
scoped_refptr<const Extension> extension = |
ExtensionBuilder() |
.SetManifest(DictionaryBuilder() |
@@ -171,16 +134,13 @@ TEST_F(ActivityLogTest, LogWithArguments) { |
.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)); |
+ policy->ProcessAction(ActivityLogPolicy::ACTION_API, *extension.get(), |
+ std::string("extension.connect"), NULL, args.get(), NULL); |
+ policy->ReadData(extension->id(), 0, |
+ base::Bind(FullStreamUIPolicyTest::Arguments_Present)); |
} |
-} // namespace extensions |
- |
+} // End of namespace extensions |