Chromium Code Reviews| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 15 #include "chrome/browser/notifications/notification_permission_context.h" | 15 #include "chrome/browser/notifications/notification_permission_context.h" |
| 16 #include "chrome/browser/notifications/notification_permission_context_factory.h " | 16 #include "chrome/browser/notifications/notification_permission_context_factory.h " |
| 17 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
| 18 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 18 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 21 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/common/content_switches.h" | |
| 26 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
| 27 #include "net/base/filename_util.h" | 27 #include "net/base/filename_util.h" |
| 28 #include "net/test/embedded_test_server/embedded_test_server.h" | 28 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 | 31 |
| 32 // ----------------------------------------------------------------------------- | 32 // ----------------------------------------------------------------------------- |
| 33 | 33 |
| 34 // Dimensions of the icon.png resource in the notification test data directory. | 34 // Dimensions of the icon.png resource in the notification test data directory. |
| 35 const int kIconWidth = 100; | 35 const int kIconWidth = 100; |
| 36 const int kIconHeight = 100; | 36 const int kIconHeight = 100; |
| 37 | 37 |
| 38 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; | 38 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; |
| 39 const double kNotificationTimestamp = 621046800000.; | 39 const double kNotificationTimestamp = 621046800000.; |
| 40 | 40 |
| 41 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { | 41 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
| 42 public: | 42 public: |
| 43 PlatformNotificationServiceBrowserTest(); | 43 PlatformNotificationServiceBrowserTest(); |
| 44 ~PlatformNotificationServiceBrowserTest() override {} | 44 ~PlatformNotificationServiceBrowserTest() override {} |
| 45 | 45 |
| 46 // InProcessBrowserTest overrides. | 46 // InProcessBrowserTest overrides. |
| 47 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 47 void SetUp() override; | 48 void SetUp() override; |
| 48 void SetUpOnMainThread() override; | 49 void SetUpOnMainThread() override; |
| 49 void TearDown() override; | 50 void TearDown() override; |
| 50 | 51 |
| 51 protected: | 52 protected: |
| 52 // Returns the Platform Notification Service these unit tests are for. | 53 // Returns the Platform Notification Service these unit tests are for. |
| 53 PlatformNotificationServiceImpl* service() const { | 54 PlatformNotificationServiceImpl* service() const { |
| 54 return PlatformNotificationServiceImpl::GetInstance(); | 55 return PlatformNotificationServiceImpl::GetInstance(); |
| 55 } | 56 } |
| 56 | 57 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 RequestAndRespondToPermission(PermissionBubbleManager::ACCEPT_ALL); | 173 RequestAndRespondToPermission(PermissionBubbleManager::ACCEPT_ALL); |
| 173 return "granted" == result; | 174 return "granted" == result; |
| 174 } | 175 } |
| 175 | 176 |
| 176 bool PlatformNotificationServiceBrowserTest::RequestAndDenyPermission() { | 177 bool PlatformNotificationServiceBrowserTest::RequestAndDenyPermission() { |
| 177 std::string result = | 178 std::string result = |
| 178 RequestAndRespondToPermission(PermissionBubbleManager::DENY_ALL); | 179 RequestAndRespondToPermission(PermissionBubbleManager::DENY_ALL); |
| 179 return "denied" == result; | 180 return "denied" == result; |
| 180 } | 181 } |
| 181 | 182 |
| 183 void PlatformNotificationServiceBrowserTest::SetUpCommandLine( | |
| 184 base::CommandLine* command_line) { | |
| 185 command_line->AppendSwtich(switches::kEnableExperimentalWebPlatformFeatures); | |
|
Peter Beverloo
2016/02/17 16:15:35
AppendSwitch
harkness
2016/02/18 10:45:14
Actually, I meant to revert this file. I'll do tha
| |
| 186 | |
| 187 InProcessBrowserTest::SetUpCommandLine(command_line); | |
| 188 } | |
| 189 | |
| 182 // ----------------------------------------------------------------------------- | 190 // ----------------------------------------------------------------------------- |
| 183 | 191 |
| 184 // TODO(peter): Move PlatformNotificationService-related tests over from | 192 // TODO(peter): Move PlatformNotificationService-related tests over from |
| 185 // notification_browsertest.cc to this file. | 193 // notification_browsertest.cc to this file. |
| 186 | 194 |
| 187 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 195 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 188 DisplayPersistentNotificationWithoutPermission) { | 196 DisplayPersistentNotificationWithoutPermission) { |
| 189 RequestAndDenyPermission(); | 197 RequestAndDenyPermission(); |
| 190 | 198 |
| 191 std::string script_result; | 199 std::string script_result; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 447 |
| 440 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 448 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| 441 | 449 |
| 442 const Notification& notification = ui_manager()->GetNotificationAt(0); | 450 const Notification& notification = ui_manager()->GetNotificationAt(0); |
| 443 EXPECT_FALSE(notification.icon().IsEmpty()); | 451 EXPECT_FALSE(notification.icon().IsEmpty()); |
| 444 | 452 |
| 445 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); | 453 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); |
| 446 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 454 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
| 447 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 455 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
| 448 } | 456 } |
| OLD | NEW |