| 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/fullstream_ui_policy.h" | 10 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(FullStreamUIPolicyTest, Construct) { | 91 TEST_F(FullStreamUIPolicyTest, Construct) { |
| 92 scoped_ptr<ActivityLogPolicy> policy(new FullStreamUIPolicy(profile_.get())); | 92 ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 93 scoped_refptr<const Extension> extension = | 93 scoped_refptr<const Extension> extension = |
| 94 ExtensionBuilder() | 94 ExtensionBuilder() |
| 95 .SetManifest(DictionaryBuilder() | 95 .SetManifest(DictionaryBuilder() |
| 96 .Set("name", "Test extension") | 96 .Set("name", "Test extension") |
| 97 .Set("version", "1.0.0") | 97 .Set("version", "1.0.0") |
| 98 .Set("manifest_version", 2)) | 98 .Set("manifest_version", 2)) |
| 99 .Build(); | 99 .Build(); |
| 100 extension_service_->AddExtension(extension.get()); | 100 extension_service_->AddExtension(extension.get()); |
| 101 scoped_ptr<base::ListValue> args(new base::ListValue()); | 101 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 102 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), | 102 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), |
| 103 std::string("tabs.testMethod"), GURL(), args.get(), NULL); | 103 std::string("tabs.testMethod"), GURL(), args.get(), NULL); |
| 104 policy->Close(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { | 107 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { |
| 107 scoped_ptr<ActivityLogPolicy> policy(new FullStreamUIPolicy(profile_.get())); | 108 ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 108 scoped_refptr<const Extension> extension = | 109 scoped_refptr<const Extension> extension = |
| 109 ExtensionBuilder() | 110 ExtensionBuilder() |
| 110 .SetManifest(DictionaryBuilder() | 111 .SetManifest(DictionaryBuilder() |
| 111 .Set("name", "Test extension") | 112 .Set("name", "Test extension") |
| 112 .Set("version", "1.0.0") | 113 .Set("version", "1.0.0") |
| 113 .Set("manifest_version", 2)) | 114 .Set("manifest_version", 2)) |
| 114 .Build(); | 115 .Build(); |
| 115 extension_service_->AddExtension(extension.get()); | 116 extension_service_->AddExtension(extension.get()); |
| 116 scoped_ptr<base::ListValue> args(new base::ListValue()); | 117 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 117 GURL gurl("http://www.google.com"); | 118 GURL gurl("http://www.google.com"); |
| 118 | 119 |
| 119 // Write some API calls | 120 // Write some API calls |
| 120 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), | 121 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), |
| 121 std::string("tabs.testMethod"), GURL(), args.get(), NULL); | 122 std::string("tabs.testMethod"), GURL(), args.get(), NULL); |
| 122 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, | 123 policy->ProcessAction(ActivityLogPolicy::ACTION_DOM, |
| 123 extension->id(), std::string("document.write"), | 124 extension->id(), std::string("document.write"), |
| 124 gurl, args.get(), NULL); | 125 gurl, args.get(), NULL); |
| 125 policy->ReadData(extension->id(), 0, | 126 policy->ReadData(extension->id(), 0, |
| 126 base::Bind(FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); | 127 base::Bind(FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); |
| 128 |
| 129 policy->Close(); |
| 127 } | 130 } |
| 128 | 131 |
| 129 TEST_F(FullStreamUIPolicyTest, LogWithArguments) { | 132 TEST_F(FullStreamUIPolicyTest, LogWithArguments) { |
| 130 scoped_ptr<ActivityLogPolicy> policy(new FullStreamUIPolicy(profile_.get())); | 133 ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 131 scoped_refptr<const Extension> extension = | 134 scoped_refptr<const Extension> extension = |
| 132 ExtensionBuilder() | 135 ExtensionBuilder() |
| 133 .SetManifest(DictionaryBuilder() | 136 .SetManifest(DictionaryBuilder() |
| 134 .Set("name", "Test extension") | 137 .Set("name", "Test extension") |
| 135 .Set("version", "1.0.0") | 138 .Set("version", "1.0.0") |
| 136 .Set("manifest_version", 2)) | 139 .Set("manifest_version", 2)) |
| 137 .Build(); | 140 .Build(); |
| 138 extension_service_->AddExtension(extension.get()); | 141 extension_service_->AddExtension(extension.get()); |
| 139 scoped_ptr<base::ListValue> args(new base::ListValue()); | 142 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 140 args->Set(0, new base::StringValue("hello")); | 143 args->Set(0, new base::StringValue("hello")); |
| 141 args->Set(1, new base::StringValue("world")); | 144 args->Set(1, new base::StringValue("world")); |
| 142 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), | 145 policy->ProcessAction(ActivityLogPolicy::ACTION_API, extension->id(), |
| 143 std::string("extension.connect"), GURL(), args.get(), NULL); | 146 std::string("extension.connect"), GURL(), args.get(), NULL); |
| 144 policy->ReadData(extension->id(), 0, | 147 policy->ReadData(extension->id(), 0, |
| 145 base::Bind(FullStreamUIPolicyTest::Arguments_Present)); | 148 base::Bind(FullStreamUIPolicyTest::Arguments_Present)); |
| 149 policy->Close(); |
| 146 } | 150 } |
| 147 | 151 |
| 148 } // namespace extensions | 152 } // namespace extensions |
| OLD | NEW |