OLD | NEW |
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 TEST_F(StreamWithoutArgsUIPolicyTest, Construct) { | 91 TEST_F(StreamWithoutArgsUIPolicyTest, Construct) { |
92 scoped_ptr<ActivityLogPolicy> policy( | 92 scoped_ptr<ActivityLogPolicy> policy( |
93 new StreamWithoutArgsUIPolicy(profile_.get())); | 93 new StreamWithoutArgsUIPolicy(profile_.get())); |
94 scoped_refptr<const Extension> extension = | 94 scoped_refptr<const Extension> extension = |
95 ExtensionBuilder() | 95 ExtensionBuilder() |
96 .SetManifest(DictionaryBuilder() | 96 .SetManifest(DictionaryBuilder() |
97 .Set("name", "Test extension") | 97 .Set("name", "Test extension") |
98 .Set("version", "1.0.0") | 98 .Set("version", "1.0.0") |
99 .Set("manifest_version", 2)) | 99 .Set("manifest_version", 2)) |
100 .Build(); | 100 .Build(); |
101 extension_service_->AddExtension(extension); | 101 extension_service_->AddExtension(extension.get()); |
102 scoped_ptr<base::ListValue> args(new base::ListValue()); | 102 scoped_ptr<base::ListValue> args(new base::ListValue()); |
103 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), | 103 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), |
104 std::string("tabs.testMethod"), GURL(), args.get(), NULL); | 104 std::string("tabs.testMethod"), GURL(), args.get(), NULL); |
105 } | 105 } |
106 | 106 |
107 TEST_F(StreamWithoutArgsUIPolicyTest, LogAndFetchActions) { | 107 TEST_F(StreamWithoutArgsUIPolicyTest, LogAndFetchActions) { |
108 scoped_ptr<ActivityLogPolicy> policy( | 108 scoped_ptr<ActivityLogPolicy> policy( |
109 new StreamWithoutArgsUIPolicy(profile_.get())); | 109 new StreamWithoutArgsUIPolicy(profile_.get())); |
110 scoped_refptr<const Extension> extension = | 110 scoped_refptr<const Extension> extension = |
111 ExtensionBuilder() | 111 ExtensionBuilder() |
112 .SetManifest(DictionaryBuilder() | 112 .SetManifest(DictionaryBuilder() |
113 .Set("name", "Test extension") | 113 .Set("name", "Test extension") |
114 .Set("version", "1.0.0") | 114 .Set("version", "1.0.0") |
115 .Set("manifest_version", 2)) | 115 .Set("manifest_version", 2)) |
116 .Build(); | 116 .Build(); |
117 extension_service_->AddExtension(extension); | 117 extension_service_->AddExtension(extension.get()); |
118 scoped_ptr<base::ListValue> args(new base::ListValue()); | 118 scoped_ptr<base::ListValue> args(new base::ListValue()); |
119 GURL gurl("http://www.google.com"); | 119 GURL gurl("http://www.google.com"); |
120 | 120 |
121 // Write some API calls | 121 // Write some API calls |
122 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), | 122 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), |
123 std::string("tabs.testMethod"), GURL(), args.get(), NULL); | 123 std::string("tabs.testMethod"), GURL(), args.get(), NULL); |
124 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, | 124 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, |
125 extension->id(), std::string("document.write"), | 125 extension->id(), std::string("document.write"), |
126 gurl, args.get(), NULL); | 126 gurl, args.get(), NULL); |
127 policy->ReadData(extension->id(), 0, | 127 policy->ReadData(extension->id(), 0, |
128 base::Bind( | 128 base::Bind( |
129 StreamWithoutArgsUIPolicyTest::RetrieveActions_LogAndFetchActions)); | 129 StreamWithoutArgsUIPolicyTest::RetrieveActions_LogAndFetchActions)); |
130 } | 130 } |
131 | 131 |
132 TEST_F(StreamWithoutArgsUIPolicyTest, LogWithoutArguments) { | 132 TEST_F(StreamWithoutArgsUIPolicyTest, LogWithoutArguments) { |
133 scoped_ptr<ActivityLogPolicy> policy( | 133 scoped_ptr<ActivityLogPolicy> policy( |
134 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); | 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 } | 150 } |
151 | 151 |
152 } // namespace extensions | 152 } // namespace extensions |
OLD | NEW |