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

Side by Side Diff: chrome/browser/notifications/extension_welcome_notification_unittest.cc

Issue 2085673002: Remove calls to MessageLoop::current() in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/extension_welcome_notification.h" 5 #include "chrome/browser/notifications/extension_welcome_notification.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/test/test_simple_task_runner.h" 15 #include "base/test/test_simple_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/notifications/notification.h" 17 #include "chrome/browser/notifications/notification.h"
18 #include "chrome/browser/prefs/pref_service_syncable_util.h" 18 #include "chrome/browser/prefs/pref_service_syncable_util.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "components/pref_registry/pref_registry_syncable.h" 22 #include "components/pref_registry/pref_registry_syncable.h"
23 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
24 #include "components/syncable_prefs/testing_pref_service_syncable.h" 24 #include "components/syncable_prefs/testing_pref_service_syncable.h"
25 #include "extensions/browser/quota_service.h"
25 #include "sync/api/fake_sync_change_processor.h" 26 #include "sync/api/fake_sync_change_processor.h"
26 #include "sync/api/sync_error_factory_mock.h" 27 #include "sync/api/sync_error_factory_mock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/message_center/fake_message_center.h" 29 #include "ui/message_center/fake_message_center.h"
29 #include "ui/message_center/notification.h" 30 #include "ui/message_center/notification.h"
30 31
31 class MockMessageCenter : public message_center::FakeMessageCenter { 32 class MockMessageCenter : public message_center::FakeMessageCenter {
32 public: 33 public:
33 MockMessageCenter() 34 MockMessageCenter()
34 : add_notification_calls_(0), 35 : add_notification_calls_(0),
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 rich_notification_data.priority = 0; 227 rich_notification_data.priority = 0;
227 Notification notification( 228 Notification notification(
228 message_center::NOTIFICATION_TYPE_BASE_FORMAT, 229 message_center::NOTIFICATION_TYPE_BASE_FORMAT,
229 base::UTF8ToUTF16("Title"), base::UTF8ToUTF16("Body"), gfx::Image(), 230 base::UTF8ToUTF16("Title"), base::UTF8ToUTF16("Body"), gfx::Image(),
230 notifier_id, base::UTF8ToUTF16("Source"), GURL("http://tests.url"), 231 notifier_id, base::UTF8ToUTF16("Source"), GURL("http://tests.url"),
231 notification_id, rich_notification_data, 232 notification_id, rich_notification_data,
232 new TestNotificationDelegate("TestNotification")); 233 new TestNotificationDelegate("TestNotification"));
233 welcome_notification_->ShowWelcomeNotificationIfNecessary(notification); 234 welcome_notification_->ShowWelcomeNotificationIfNecessary(notification);
234 } 235 }
235 236
237 extensions::QuotaService::ScopedDisablePurgeForTesting
238 disable_purge_for_testing_;
236 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 239 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
237 std::unique_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_; 240 std::unique_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_;
238 std::unique_ptr<TestingProfile> profile_; 241 std::unique_ptr<TestingProfile> profile_;
239 // Weak Ref owned by welcome_notification_ 242 // Weak Ref owned by welcome_notification_
240 WelcomeNotificationDelegate* delegate_; 243 WelcomeNotificationDelegate* delegate_;
241 std::unique_ptr<ExtensionWelcomeNotification> welcome_notification_; 244 std::unique_ptr<ExtensionWelcomeNotification> welcome_notification_;
242 245
243 DISALLOW_COPY_AND_ASSIGN(ExtensionWelcomeNotificationTest); 246 DISALLOW_COPY_AND_ASSIGN(ExtensionWelcomeNotificationTest);
244 }; 247 };
245 248
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 530
528 EXPECT_TRUE(task_runner()->GetPendingTasks().empty()); 531 EXPECT_TRUE(task_runner()->GetPendingTasks().empty());
529 EXPECT_EQ(message_center()->add_notification_calls(), 0); 532 EXPECT_EQ(message_center()->add_notification_calls(), 0);
530 EXPECT_EQ(message_center()->remove_notification_calls(), 0); 533 EXPECT_EQ(message_center()->remove_notification_calls(), 0);
531 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0); 534 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0);
532 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed)); 535 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed));
533 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal)); 536 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal));
534 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp)); 537 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp));
535 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1); 538 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1);
536 } 539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698