OLD | NEW |
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "chrome/browser/notifications/notification.h" | 15 #include "chrome/browser/notifications/notification.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/test/base/testing_browser_process.h" |
17 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
19 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
20 #include "sync/api/fake_sync_change_processor.h" | 21 #include "sync/api/fake_sync_change_processor.h" |
21 #include "sync/api/sync_error_factory_mock.h" | 22 #include "sync/api/sync_error_factory_mock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/message_center/fake_message_center.h" | 24 #include "ui/message_center/fake_message_center.h" |
24 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
25 | 26 |
26 class MockMessageCenter : public message_center::FakeMessageCenter { | 27 class MockMessageCenter : public message_center::FakeMessageCenter { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 profile_.reset(new TestingProfile()); | 136 profile_.reset(new TestingProfile()); |
136 delegate_ = new WelcomeNotificationDelegate(); | 137 delegate_ = new WelcomeNotificationDelegate(); |
137 welcome_notification_.reset( | 138 welcome_notification_.reset( |
138 ExtensionWelcomeNotification::Create(profile_.get(), delegate_)); | 139 ExtensionWelcomeNotification::Create(profile_.get(), delegate_)); |
139 } | 140 } |
140 | 141 |
141 void TearDown() override { | 142 void TearDown() override { |
142 delegate_ = NULL; | 143 delegate_ = NULL; |
143 welcome_notification_.reset(); | 144 welcome_notification_.reset(); |
144 profile_.reset(); | 145 profile_.reset(); |
| 146 TestingBrowserProcess::DeleteInstance(); |
145 thread_task_runner_handle_.reset(); | 147 thread_task_runner_handle_.reset(); |
146 task_runner_ = NULL; | 148 task_runner_ = NULL; |
147 } | 149 } |
148 | 150 |
149 void StartPreferenceSyncing() const { | 151 void StartPreferenceSyncing() const { |
150 PrefServiceSyncable::FromProfile(profile_.get()) | 152 PrefServiceSyncable::FromProfile(profile_.get()) |
151 ->GetSyncableService(syncer::PREFERENCES) | 153 ->GetSyncableService(syncer::PREFERENCES) |
152 ->MergeDataAndStartSyncing(syncer::PREFERENCES, | 154 ->MergeDataAndStartSyncing(syncer::PREFERENCES, |
153 syncer::SyncDataList(), | 155 syncer::SyncDataList(), |
154 scoped_ptr<syncer::SyncChangeProcessor>( | 156 scoped_ptr<syncer::SyncChangeProcessor>( |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 528 |
527 EXPECT_TRUE(task_runner()->GetPendingTasks().empty()); | 529 EXPECT_TRUE(task_runner()->GetPendingTasks().empty()); |
528 EXPECT_EQ(message_center()->add_notification_calls(), 0); | 530 EXPECT_EQ(message_center()->add_notification_calls(), 0); |
529 EXPECT_EQ(message_center()->remove_notification_calls(), 0); | 531 EXPECT_EQ(message_center()->remove_notification_calls(), 0); |
530 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0); | 532 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0); |
531 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed)); | 533 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed)); |
532 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal)); | 534 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal)); |
533 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp)); | 535 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp)); |
534 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1); | 536 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1); |
535 } | 537 } |
OLD | NEW |