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