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/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "chrome/browser/extensions/activity_log/activity_log.h" | 8 #include "chrome/browser/extensions/activity_log/activity_log.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/test_extension_system.h" | 10 #include "chrome/browser/extensions/test_extension_system.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 std::string("document.write"), | 133 std::string("document.write"), |
134 args.get(), | 134 args.get(), |
135 std::string("extra")); | 135 std::string("extra")); |
136 activity_log->GetActions( | 136 activity_log->GetActions( |
137 extension->id(), | 137 extension->id(), |
138 0, | 138 0, |
139 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); | 139 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); |
140 } | 140 } |
141 | 141 |
142 TEST_F(ActivityLogTest, LogWithoutArguments) { | 142 TEST_F(ActivityLogTest, LogWithoutArguments) { |
| 143 ActivityLog::SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); |
143 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 144 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
144 activity_log->SetArgumentLoggingForTesting(false); | |
145 scoped_refptr<const Extension> extension = | 145 scoped_refptr<const Extension> extension = |
146 ExtensionBuilder() | 146 ExtensionBuilder() |
147 .SetManifest(DictionaryBuilder() | 147 .SetManifest(DictionaryBuilder() |
148 .Set("name", "Test extension") | 148 .Set("name", "Test extension") |
149 .Set("version", "1.0.0") | 149 .Set("version", "1.0.0") |
150 .Set("manifest_version", 2)) | 150 .Set("manifest_version", 2)) |
151 .Build(); | 151 .Build(); |
152 extension_service_->AddExtension(extension); | 152 extension_service_->AddExtension(extension); |
153 ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 153 ASSERT_TRUE(ActivityLog::IsLogEnabled()); |
154 | 154 |
155 scoped_ptr<ListValue> args(new ListValue()); | 155 scoped_ptr<ListValue> args(new ListValue()); |
156 args->Set(0, new base::StringValue("hello")); | 156 args->Set(0, new base::StringValue("hello")); |
157 args->Set(1, new base::StringValue("world")); | 157 args->Set(1, new base::StringValue("world")); |
158 activity_log->LogAPIAction( | 158 activity_log->LogAPIAction( |
159 extension, std::string("tabs.testMethod"), args.get(), std::string()); | 159 extension, std::string("tabs.testMethod"), args.get(), std::string()); |
160 activity_log->GetActions( | 160 activity_log->GetActions( |
161 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Missing)); | 161 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Missing)); |
162 } | 162 } |
163 | 163 |
164 TEST_F(ActivityLogTest, LogWithArguments) { | 164 TEST_F(ActivityLogTest, LogWithArguments) { |
| 165 ActivityLog::SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
165 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); | 166 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); |
166 scoped_refptr<const Extension> extension = | 167 scoped_refptr<const Extension> extension = |
167 ExtensionBuilder() | 168 ExtensionBuilder() |
168 .SetManifest(DictionaryBuilder() | 169 .SetManifest(DictionaryBuilder() |
169 .Set("name", "Test extension") | 170 .Set("name", "Test extension") |
170 .Set("version", "1.0.0") | 171 .Set("version", "1.0.0") |
171 .Set("manifest_version", 2)) | 172 .Set("manifest_version", 2)) |
172 .Build(); | 173 .Build(); |
173 extension_service_->AddExtension(extension); | 174 extension_service_->AddExtension(extension); |
174 ASSERT_TRUE(ActivityLog::IsLogEnabled()); | 175 ASSERT_TRUE(ActivityLog::IsLogEnabled()); |
175 | 176 |
176 scoped_ptr<ListValue> args(new ListValue()); | 177 scoped_ptr<ListValue> args(new ListValue()); |
177 args->Set(0, new base::StringValue("hello")); | 178 args->Set(0, new base::StringValue("hello")); |
178 args->Set(1, new base::StringValue("world")); | 179 args->Set(1, new base::StringValue("world")); |
179 activity_log->LogAPIAction( | 180 activity_log->LogAPIAction( |
180 extension, std::string("extension.connect"), args.get(), std::string()); | 181 extension, std::string("extension.connect"), args.get(), std::string()); |
181 activity_log->GetActions( | 182 activity_log->GetActions( |
182 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Present)); | 183 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Present)); |
183 } | 184 } |
184 | 185 |
185 } // namespace extensions | 186 } // namespace extensions |
186 | 187 |
OLD | NEW |