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

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

Issue 2919933002: Revert of ChromeOS: Per-user time zone: refactor tests first. (Closed)
Patch Set: Created 3 years, 6 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
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 "chrome/browser/extensions/activity_log/activity_log.h" 5 #include "chrome/browser/extensions/activity_log/activity_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "extensions/browser/extension_registry.h" 29 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/uninstall_reason.h" 30 #include "extensions/browser/uninstall_reason.h"
31 #include "extensions/common/dom_action_types.h" 31 #include "extensions/common/dom_action_types.h"
32 #include "extensions/common/extension_builder.h" 32 #include "extensions/common/extension_builder.h"
33 #include "extensions/common/test_util.h" 33 #include "extensions/common/test_util.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 35
36 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
38 #include "chrome/browser/chromeos/settings/cros_settings.h"
39 #include "chrome/browser/chromeos/settings/device_settings_service.h"
40 #endif
41
36 namespace { 42 namespace {
37 43
38 const char kExtensionId[] = "abc"; 44 const char kExtensionId[] = "abc";
39 45
40 const char* const kUrlApiCalls[] = { 46 const char* const kUrlApiCalls[] = {
41 "HTMLButtonElement.formAction", "HTMLEmbedElement.src", 47 "HTMLButtonElement.formAction", "HTMLEmbedElement.src",
42 "HTMLFormElement.action", "HTMLFrameElement.src", 48 "HTMLFormElement.action", "HTMLFrameElement.src",
43 "HTMLHtmlElement.manifest", "HTMLIFrameElement.src", 49 "HTMLHtmlElement.manifest", "HTMLIFrameElement.src",
44 "HTMLImageElement.longDesc", "HTMLImageElement.src", 50 "HTMLImageElement.longDesc", "HTMLImageElement.src",
45 "HTMLImageElement.lowsrc", "HTMLInputElement.formAction", 51 "HTMLImageElement.lowsrc", "HTMLInputElement.formAction",
46 "HTMLInputElement.src", "HTMLLinkElement.href", 52 "HTMLInputElement.src", "HTMLLinkElement.href",
47 "HTMLMediaElement.src", "HTMLMediaElement.currentSrc", 53 "HTMLMediaElement.src", "HTMLMediaElement.currentSrc",
48 "HTMLModElement.cite", "HTMLObjectElement.data", 54 "HTMLModElement.cite", "HTMLObjectElement.data",
49 "HTMLQuoteElement.cite", "HTMLScriptElement.src", 55 "HTMLQuoteElement.cite", "HTMLScriptElement.src",
50 "HTMLSourceElement.src", "HTMLTrackElement.src", 56 "HTMLSourceElement.src", "HTMLTrackElement.src",
51 "HTMLVideoElement.poster"}; 57 "HTMLVideoElement.poster"};
52 58
53 } // namespace 59 } // namespace
54 60
55 namespace extensions { 61 namespace extensions {
56 62
57 class ActivityLogTest : public ChromeRenderViewHostTestHarness { 63 class ActivityLogTest : public ChromeRenderViewHostTestHarness {
58 protected: 64 protected:
59 virtual bool enable_activity_logging_switch() const { return true; } 65 virtual bool enable_activity_logging_switch() const { return true; }
60 void SetUp() override { 66 void SetUp() override {
61 ChromeRenderViewHostTestHarness::SetUp(); 67 ChromeRenderViewHostTestHarness::SetUp();
68 #if defined OS_CHROMEOS
69 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
70 #endif
62 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 71 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
63 if (enable_activity_logging_switch()) { 72 if (enable_activity_logging_switch()) {
64 base::CommandLine::ForCurrentProcess()->AppendSwitch( 73 base::CommandLine::ForCurrentProcess()->AppendSwitch(
65 switches::kEnableExtensionActivityLogging); 74 switches::kEnableExtensionActivityLogging);
66 } 75 }
67 base::CommandLine::ForCurrentProcess()->AppendSwitch( 76 base::CommandLine::ForCurrentProcess()->AppendSwitch(
68 switches::kEnableExtensionActivityLogTesting); 77 switches::kEnableExtensionActivityLogTesting);
69 extension_service_ = static_cast<TestExtensionSystem*>( 78 extension_service_ = static_cast<TestExtensionSystem*>(
70 ExtensionSystem::Get(profile()))->CreateExtensionService 79 ExtensionSystem::Get(profile()))->CreateExtensionService
71 (&command_line, base::FilePath(), false); 80 (&command_line, base::FilePath(), false);
72 base::RunLoop().RunUntilIdle(); 81 base::RunLoop().RunUntilIdle();
73 } 82 }
74 83
75 void TearDown() override { 84 void TearDown() override {
85 #if defined OS_CHROMEOS
86 test_user_manager_.reset();
87 #endif
76 base::RunLoop().RunUntilIdle(); 88 base::RunLoop().RunUntilIdle();
77 ChromeRenderViewHostTestHarness::TearDown(); 89 ChromeRenderViewHostTestHarness::TearDown();
78 } 90 }
79 91
80 static void RetrieveActions_LogAndFetchActions0( 92 static void RetrieveActions_LogAndFetchActions0(
81 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { 93 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) {
82 ASSERT_EQ(0, static_cast<int>(i->size())); 94 ASSERT_EQ(0, static_cast<int>(i->size()));
83 } 95 }
84 96
85 static void RetrieveActions_LogAndFetchActions2( 97 static void RetrieveActions_LogAndFetchActions2(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 ASSERT_EQ("http://www.google.co.uk/", action->arg_url().spec()); 191 ASSERT_EQ("http://www.google.co.uk/", action->arg_url().spec());
180 other = action->other(); 192 other = action->other();
181 ASSERT_TRUE(other); 193 ASSERT_TRUE(other);
182 ASSERT_TRUE( 194 ASSERT_TRUE(
183 other->GetInteger(activity_log_constants::kActionDomVerb, &dom_verb)); 195 other->GetInteger(activity_log_constants::kActionDomVerb, &dom_verb));
184 ASSERT_EQ(DomActionType::SETTER, dom_verb); 196 ASSERT_EQ(DomActionType::SETTER, dom_verb);
185 } 197 }
186 } 198 }
187 199
188 ExtensionService* extension_service_; 200 ExtensionService* extension_service_;
201
202 #if defined OS_CHROMEOS
203 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
204 chromeos::ScopedTestCrosSettings test_cros_settings_;
205 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
206 #endif
189 }; 207 };
190 208
191 TEST_F(ActivityLogTest, Construct) { 209 TEST_F(ActivityLogTest, Construct) {
192 ASSERT_TRUE(GetDatabaseEnabled()); 210 ASSERT_TRUE(GetDatabaseEnabled());
193 ASSERT_FALSE(GetWatchdogActive()); 211 ASSERT_FALSE(GetWatchdogActive());
194 } 212 }
195 213
196 TEST_F(ActivityLogTest, LogAndFetchActions) { 214 TEST_F(ActivityLogTest, LogAndFetchActions) {
197 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); 215 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
198 std::unique_ptr<base::ListValue> args(new base::ListValue()); 216 std::unique_ptr<base::ListValue> args(new base::ListValue());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 EXPECT_TRUE(activity_log->ShouldLog(empty_extension->id())); 447 EXPECT_TRUE(activity_log->ShouldLog(empty_extension->id()));
430 // ... but not those of the watchdog app. 448 // ... but not those of the watchdog app.
431 EXPECT_FALSE(activity_log->ShouldLog(activity_log_extension->id())); 449 EXPECT_FALSE(activity_log->ShouldLog(activity_log_extension->id()));
432 extension_service_->DisableExtension(activity_log_extension->id(), 450 extension_service_->DisableExtension(activity_log_extension->id(),
433 Extension::DISABLE_USER_ACTION); 451 Extension::DISABLE_USER_ACTION);
434 // Disabling the watchdog app means that we're back to never logging anything. 452 // Disabling the watchdog app means that we're back to never logging anything.
435 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id())); 453 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id()));
436 } 454 }
437 455
438 } // namespace extensions 456 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698