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

Side by Side Diff: chrome/browser/extensions/activity_log/stream_noargs_ui_policy_unittest.cc

Issue 18660004: Extension activity log database refactoring (step 1) (Closed) Base URL: http://git.chromium.org/chromium/src.git@incognito-tests
Patch Set: Delegate renaming and comment cleanup Created 7 years, 5 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
« no previous file with comments | « chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "chrome/browser/extensions/activity_log/activity_log.h" 9 #include "chrome/browser/extensions/activity_log/activity_log.h"
10 #include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h" 10 #include "chrome/browser/extensions/activity_log/stream_noargs_ui_policy.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 CommandLine saved_cmdline_; 82 CommandLine saved_cmdline_;
83 83
84 #if defined OS_CHROMEOS 84 #if defined OS_CHROMEOS
85 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 85 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
86 chromeos::ScopedTestCrosSettings test_cros_settings_; 86 chromeos::ScopedTestCrosSettings test_cros_settings_;
87 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; 87 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
88 #endif 88 #endif
89 }; 89 };
90 90
91 TEST_F(StreamWithoutArgsUIPolicyTest, Construct) { 91 TEST_F(StreamWithoutArgsUIPolicyTest, Construct) {
92 scoped_ptr<ActivityLogPolicy> policy( 92 ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_.get());
93 new StreamWithoutArgsUIPolicy(profile_.get()));
94 scoped_refptr<const Extension> extension = 93 scoped_refptr<const Extension> extension =
95 ExtensionBuilder() 94 ExtensionBuilder()
96 .SetManifest(DictionaryBuilder() 95 .SetManifest(DictionaryBuilder()
97 .Set("name", "Test extension") 96 .Set("name", "Test extension")
98 .Set("version", "1.0.0") 97 .Set("version", "1.0.0")
99 .Set("manifest_version", 2)) 98 .Set("manifest_version", 2))
100 .Build(); 99 .Build();
101 extension_service_->AddExtension(extension.get()); 100 extension_service_->AddExtension(extension.get());
102 scoped_ptr<base::ListValue> args(new base::ListValue()); 101 scoped_ptr<base::ListValue> args(new base::ListValue());
103 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), 102 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(),
104 std::string("tabs.testMethod"), GURL(), args.get(), NULL); 103 std::string("tabs.testMethod"), GURL(), args.get(), NULL);
104 policy->Close();
105 } 105 }
106 106
107 TEST_F(StreamWithoutArgsUIPolicyTest, LogAndFetchActions) { 107 TEST_F(StreamWithoutArgsUIPolicyTest, LogAndFetchActions) {
108 scoped_ptr<ActivityLogPolicy> policy( 108 ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_.get());
109 new StreamWithoutArgsUIPolicy(profile_.get()));
110 scoped_refptr<const Extension> extension = 109 scoped_refptr<const Extension> extension =
111 ExtensionBuilder() 110 ExtensionBuilder()
112 .SetManifest(DictionaryBuilder() 111 .SetManifest(DictionaryBuilder()
113 .Set("name", "Test extension") 112 .Set("name", "Test extension")
114 .Set("version", "1.0.0") 113 .Set("version", "1.0.0")
115 .Set("manifest_version", 2)) 114 .Set("manifest_version", 2))
116 .Build(); 115 .Build();
117 extension_service_->AddExtension(extension.get()); 116 extension_service_->AddExtension(extension.get());
118 scoped_ptr<base::ListValue> args(new base::ListValue()); 117 scoped_ptr<base::ListValue> args(new base::ListValue());
119 GURL gurl("http://www.google.com"); 118 GURL gurl("http://www.google.com");
120 119
121 // Write some API calls 120 // Write some API calls
122 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), 121 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(),
123 std::string("tabs.testMethod"), GURL(), args.get(), NULL); 122 std::string("tabs.testMethod"), GURL(), args.get(), NULL);
124 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, 123 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM,
125 extension->id(), std::string("document.write"), 124 extension->id(), std::string("document.write"),
126 gurl, args.get(), NULL); 125 gurl, args.get(), NULL);
127 policy->ReadData(extension->id(), 0, 126 policy->ReadData(extension->id(), 0,
128 base::Bind( 127 base::Bind(
129 StreamWithoutArgsUIPolicyTest::RetrieveActions_LogAndFetchActions)); 128 StreamWithoutArgsUIPolicyTest::RetrieveActions_LogAndFetchActions));
129
130 policy->Close();
130 } 131 }
131 132
132 TEST_F(StreamWithoutArgsUIPolicyTest, LogWithoutArguments) { 133 TEST_F(StreamWithoutArgsUIPolicyTest, LogWithoutArguments) {
133 scoped_ptr<ActivityLogPolicy> policy( 134 ActivityLogPolicy* policy = new StreamWithoutArgsUIPolicy(profile_.get());
134 new StreamWithoutArgsUIPolicy(profile_.get()));
135 scoped_refptr<const Extension> extension = 135 scoped_refptr<const Extension> extension =
136 ExtensionBuilder() 136 ExtensionBuilder()
137 .SetManifest(DictionaryBuilder() 137 .SetManifest(DictionaryBuilder()
138 .Set("name", "Test extension") 138 .Set("name", "Test extension")
139 .Set("version", "1.0.0") 139 .Set("version", "1.0.0")
140 .Set("manifest_version", 2)) 140 .Set("manifest_version", 2))
141 .Build(); 141 .Build();
142 extension_service_->AddExtension(extension.get()); 142 extension_service_->AddExtension(extension.get());
143 scoped_ptr<base::ListValue> args(new base::ListValue()); 143 scoped_ptr<base::ListValue> args(new base::ListValue());
144 args->Set(0, new base::StringValue("hello")); 144 args->Set(0, new base::StringValue("hello"));
145 args->Set(1, new base::StringValue("world")); 145 args->Set(1, new base::StringValue("world"));
146 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), 146 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(),
147 std::string("tabs.testMethod"), GURL(), args.get(), NULL); 147 std::string("tabs.testMethod"), GURL(), args.get(), NULL);
148 policy->ReadData(extension->id(), 0, 148 policy->ReadData(extension->id(), 0,
149 base::Bind(StreamWithoutArgsUIPolicyTest::Arguments_Missing)); 149 base::Bind(StreamWithoutArgsUIPolicyTest::Arguments_Missing));
150 policy->Close();
150 } 151 }
151 152
152 } // namespace extensions 153 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698