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

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

Issue 2833993002: Enable MacOSX native notifications by default (Closed)
Patch Set: review Created 3 years, 8 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
18 #include "chrome/browser/notifications/message_center_display_service.h" 19 #include "chrome/browser/notifications/message_center_display_service.h"
19 #include "chrome/browser/notifications/notification_delegate.h" 20 #include "chrome/browser/notifications/notification_delegate.h"
20 #include "chrome/browser/notifications/notification_display_service_factory.h" 21 #include "chrome/browser/notifications/notification_display_service_factory.h"
21 #include "chrome/browser/notifications/notification_test_util.h" 22 #include "chrome/browser/notifications/notification_test_util.h"
22 #include "chrome/browser/notifications/platform_notification_service_impl.h" 23 #include "chrome/browser/notifications/platform_notification_service_impl.h"
23 #include "chrome/browser/notifications/stub_notification_platform_bridge.h" 24 #include "chrome/browser/notifications/stub_notification_platform_bridge.h"
25 #include "chrome/common/chrome_features.h"
24 #include "chrome/test/base/testing_browser_process.h" 26 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/testing_profile_manager.h" 28 #include "chrome/test/base/testing_profile_manager.h"
27 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
28 #include "content/public/browser/desktop_notification_delegate.h" 30 #include "content/public/browser/desktop_notification_delegate.h"
29 #include "content/public/common/notification_resources.h" 31 #include "content/public/common/notification_resources.h"
30 #include "content/public/common/platform_notification_data.h" 32 #include "content/public/common/platform_notification_data.h"
31 #include "content/public/test/test_browser_thread_bundle.h" 33 #include "content/public/test/test_browser_thread_bundle.h"
32 #include "extensions/features/features.h" 34 #include "extensions/features/features.h"
33 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 162
161 EXPECT_TRUE(displayed_notifications_.get()); 163 EXPECT_TRUE(displayed_notifications_.get());
162 return displayed_notifications_->size(); 164 return displayed_notifications_->size();
163 } 165 }
164 166
165 Notification GetDisplayedNotification() { 167 Notification GetDisplayedNotification() {
166 #if defined(OS_ANDROID) 168 #if defined(OS_ANDROID)
167 return static_cast<StubNotificationPlatformBridge*>( 169 return static_cast<StubNotificationPlatformBridge*>(
168 g_browser_process->notification_platform_bridge()) 170 g_browser_process->notification_platform_bridge())
169 ->GetNotificationAt(profile_->GetPath().BaseName().value(), 0); 171 ->GetNotificationAt(profile_->GetPath().BaseName().value(), 0);
172 #elif BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
173 if (base::FeatureList::IsEnabled(features::kNativeNotifications)) {
174 return static_cast<StubNotificationPlatformBridge*>(
175 g_browser_process->notification_platform_bridge())
176 ->GetNotificationAt(profile_->GetPath().BaseName().value(), 0);
177 } else {
178 return static_cast<StubNotificationUIManager*>(
179 g_browser_process->notification_ui_manager())
180 ->GetNotificationAt(0);
181 }
170 #else 182 #else
171 return static_cast<StubNotificationUIManager*>( 183 return static_cast<StubNotificationUIManager*>(
172 g_browser_process->notification_ui_manager()) 184 g_browser_process->notification_ui_manager())
173 ->GetNotificationAt(0); 185 ->GetNotificationAt(0);
174 #endif 186 #endif
175 } 187 }
176 188
177 private: 189 private:
178 NotificationDisplayService* display_service() const { 190 NotificationDisplayService* display_service() const {
179 return NotificationDisplayServiceFactory::GetForProfile(profile_); 191 return NotificationDisplayServiceFactory::GetForProfile(profile_);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 profile(), 437 profile(),
426 GURL() /* service_worker_scope */, 438 GURL() /* service_worker_scope */,
427 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 439 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
428 notification_data, NotificationResources(), 440 notification_data, NotificationResources(),
429 new MockNotificationDelegate("hello")); 441 new MockNotificationDelegate("hello"));
430 EXPECT_EQ("NotificationTest", 442 EXPECT_EQ("NotificationTest",
431 base::UTF16ToUTF8(notification.context_message())); 443 base::UTF16ToUTF8(notification.context_message()));
432 } 444 }
433 445
434 #endif // BUILDFLAG(ENABLE_EXTENSIONS) 446 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_interactive_uitest_support.cc ('k') | chrome/common/chrome_features.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698