Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/extensions/activity_log_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 8 #include "chrome/browser/extensions/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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 scoped_refptr<const Extension> extension = 86 scoped_refptr<const Extension> extension =
87 ExtensionBuilder() 87 ExtensionBuilder()
88 .SetManifest(DictionaryBuilder() 88 .SetManifest(DictionaryBuilder()
89 .Set("name", "Test extension") 89 .Set("name", "Test extension")
90 .Set("version", "1.0.0") 90 .Set("version", "1.0.0")
91 .Set("manifest_version", 2)) 91 .Set("manifest_version", 2))
92 .Build(); 92 .Build();
93 extension_service_->AddExtension(extension); 93 extension_service_->AddExtension(extension);
94 scoped_ptr<ListValue> args(new ListValue()); 94 scoped_ptr<ListValue> args(new ListValue());
95 ASSERT_TRUE(ActivityLog::IsLogEnabled()); 95 ASSERT_TRUE(ActivityLog::IsLogEnabled());
96 activity_log->LogAPIAction(extension, 96 activity_log->LogAPIAction(
97 std::string("tabs.testMethod"), 97 extension, std::string("tabs.testMethod"), args.get(), std::string());
98 args.get(),
99 "");
100 } 98 }
101 99
102 TEST_F(ActivityLogTest, LogAndFetchActions) { 100 TEST_F(ActivityLogTest, LogAndFetchActions) {
103 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); 101 ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
104 scoped_refptr<const Extension> extension = 102 scoped_refptr<const Extension> extension =
105 ExtensionBuilder() 103 ExtensionBuilder()
106 .SetManifest(DictionaryBuilder() 104 .SetManifest(DictionaryBuilder()
107 .Set("name", "Test extension") 105 .Set("name", "Test extension")
108 .Set("version", "1.0.0") 106 .Set("version", "1.0.0")
109 .Set("manifest_version", 2)) 107 .Set("manifest_version", 2))
110 .Build(); 108 .Build();
111 extension_service_->AddExtension(extension); 109 extension_service_->AddExtension(extension);
112 scoped_ptr<ListValue> args(new ListValue()); 110 scoped_ptr<ListValue> args(new ListValue());
113 ASSERT_TRUE(ActivityLog::IsLogEnabled()); 111 ASSERT_TRUE(ActivityLog::IsLogEnabled());
114 112
115 // Write some API calls 113 // Write some API calls
116 activity_log->LogAPIAction(extension, 114 activity_log->LogAPIAction(
117 std::string("tabs.testMethod"), 115 extension, std::string("tabs.testMethod"), args.get(), std::string());
118 args.get(),
119 "");
120 activity_log->LogDOMAction(extension, 116 activity_log->LogDOMAction(extension,
121 GURL("http://www.google.com"), 117 GURL("http://www.google.com"),
122 string16(), 118 string16(),
123 std::string("document.write"), 119 std::string("document.write"),
124 args.get(), 120 args.get(),
125 std::string("extra")); 121 std::string("extra"));
126 activity_log->GetActions( 122 activity_log->GetActions(
127 extension->id(), 123 extension->id(),
128 0, 124 0,
129 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); 125 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions));
130 } 126 }
131 127
132 TEST_F(ActivityLogTest, LogWithoutArguments) { 128 TEST_F(ActivityLogTest, LogWithoutArguments) {
133 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); 129 ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
134 scoped_refptr<const Extension> extension = 130 scoped_refptr<const Extension> extension =
135 ExtensionBuilder() 131 ExtensionBuilder()
136 .SetManifest(DictionaryBuilder() 132 .SetManifest(DictionaryBuilder()
137 .Set("name", "Test extension") 133 .Set("name", "Test extension")
138 .Set("version", "1.0.0") 134 .Set("version", "1.0.0")
139 .Set("manifest_version", 2)) 135 .Set("manifest_version", 2))
140 .Build(); 136 .Build();
141 extension_service_->AddExtension(extension); 137 extension_service_->AddExtension(extension);
142 ASSERT_TRUE(ActivityLog::IsLogEnabled()); 138 ASSERT_TRUE(ActivityLog::IsLogEnabled());
143 139
144 scoped_ptr<ListValue> args(new ListValue()); 140 scoped_ptr<ListValue> args(new ListValue());
145 args->Set(0, new base::StringValue("hello")); 141 args->Set(0, new base::StringValue("hello"));
146 args->Set(1, new base::StringValue("world")); 142 args->Set(1, new base::StringValue("world"));
147 activity_log->LogAPIAction(extension, 143 activity_log->LogAPIAction(
148 std::string("tabs.testMethod"), 144 extension, std::string("tabs.testMethod"), args.get(), std::string());
149 args.get(),
150 "");
151 activity_log->GetActions( 145 activity_log->GetActions(
152 extension->id(), 146 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Missing));
153 0,
154 base::Bind(ActivityLogTest::Arguments_Missing));
155 } 147 }
156 148
157 TEST_F(ActivityLogTest, LogWithArguments) { 149 TEST_F(ActivityLogTest, LogWithArguments) {
158 ActivityLog* activity_log = ActivityLog::GetInstance(profile_); 150 ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
159 scoped_refptr<const Extension> extension = 151 scoped_refptr<const Extension> extension =
160 ExtensionBuilder() 152 ExtensionBuilder()
161 .SetManifest(DictionaryBuilder() 153 .SetManifest(DictionaryBuilder()
162 .Set("name", "Test extension") 154 .Set("name", "Test extension")
163 .Set("version", "1.0.0") 155 .Set("version", "1.0.0")
164 .Set("manifest_version", 2)) 156 .Set("manifest_version", 2))
165 .Build(); 157 .Build();
166 extension_service_->AddExtension(extension); 158 extension_service_->AddExtension(extension);
167 ASSERT_TRUE(ActivityLog::IsLogEnabled()); 159 ASSERT_TRUE(ActivityLog::IsLogEnabled());
168 160
169 scoped_ptr<ListValue> args(new ListValue()); 161 scoped_ptr<ListValue> args(new ListValue());
170 args->Set(0, new base::StringValue("hello")); 162 args->Set(0, new base::StringValue("hello"));
171 args->Set(1, new base::StringValue("world")); 163 args->Set(1, new base::StringValue("world"));
172 activity_log->LogAPIAction(extension, 164 activity_log->LogAPIAction(
173 std::string("extension.connect"), 165 extension, std::string("extension.connect"), args.get(), std::string());
174 args.get(),
175 "");
176 activity_log->GetActions( 166 activity_log->GetActions(
177 extension->id(), 167 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Present));
178 0,
179 base::Bind(ActivityLogTest::Arguments_Present));
180 } 168 }
181 169
182 } // namespace extensions 170 } // namespace extensions
183 171
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log.cc ('k') | chrome/browser/extensions/api/alarms/alarms_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698