| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom.h" | 32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 | 34 |
| 35 // ----------------------------------------------------------------------------- | 35 // ----------------------------------------------------------------------------- |
| 36 | 36 |
| 37 // Dimensions of the icon.png resource in the notification test data directory. | 37 // Dimensions of the icon.png resource in the notification test data directory. |
| 38 const int kIconWidth = 100; | 38 const int kIconWidth = 100; |
| 39 const int kIconHeight = 100; | 39 const int kIconHeight = 100; |
| 40 | 40 |
| 41 // The maximum width and height of badges. Oversized images are scaled down to | |
| 42 // these values. | |
| 43 const int kMaxBadgeSize = 96; | |
| 44 | |
| 45 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; | 41 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; |
| 46 const double kNotificationTimestamp = 621046800000.; | 42 const double kNotificationTimestamp = 621046800000.; |
| 47 | 43 |
| 48 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { | 44 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
| 49 public: | 45 public: |
| 50 PlatformNotificationServiceBrowserTest(); | 46 PlatformNotificationServiceBrowserTest(); |
| 51 ~PlatformNotificationServiceBrowserTest() override {} | 47 ~PlatformNotificationServiceBrowserTest() override {} |
| 52 | 48 |
| 53 // InProcessBrowserTest overrides. | 49 // InProcessBrowserTest overrides. |
| 54 void SetUpCommandLine(base::CommandLine* command_line) override; | 50 void SetUpCommandLine(base::CommandLine* command_line) override; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 269 |
| 274 // We don't use or check the notification's direction and language. | 270 // We don't use or check the notification's direction and language. |
| 275 const Notification& all_options_notification = | 271 const Notification& all_options_notification = |
| 276 ui_manager()->GetNotificationAt(1); | 272 ui_manager()->GetNotificationAt(1); |
| 277 EXPECT_EQ("Title", base::UTF16ToUTF8(all_options_notification.title())); | 273 EXPECT_EQ("Title", base::UTF16ToUTF8(all_options_notification.title())); |
| 278 EXPECT_EQ("Contents", base::UTF16ToUTF8(all_options_notification.message())); | 274 EXPECT_EQ("Contents", base::UTF16ToUTF8(all_options_notification.message())); |
| 279 EXPECT_EQ("replace-id", all_options_notification.tag()); | 275 EXPECT_EQ("replace-id", all_options_notification.tag()); |
| 280 EXPECT_FALSE(all_options_notification.icon().IsEmpty()); | 276 EXPECT_FALSE(all_options_notification.icon().IsEmpty()); |
| 281 EXPECT_EQ(kIconWidth, all_options_notification.icon().Width()); | 277 EXPECT_EQ(kIconWidth, all_options_notification.icon().Width()); |
| 282 EXPECT_EQ(kIconHeight, all_options_notification.icon().Height()); | 278 EXPECT_EQ(kIconHeight, all_options_notification.icon().Height()); |
| 283 EXPECT_FALSE(all_options_notification.small_image().IsEmpty()); | 279 EXPECT_TRUE(all_options_notification.small_image().IsEmpty()); |
| 284 EXPECT_EQ(kMaxBadgeSize, all_options_notification.small_image().Width()); | |
| 285 EXPECT_EQ(kMaxBadgeSize, all_options_notification.small_image().Height()); | |
| 286 EXPECT_TRUE(all_options_notification.renotify()); | 280 EXPECT_TRUE(all_options_notification.renotify()); |
| 287 EXPECT_TRUE(all_options_notification.silent()); | 281 EXPECT_TRUE(all_options_notification.silent()); |
| 288 EXPECT_TRUE(all_options_notification.never_timeout()); | 282 EXPECT_TRUE(all_options_notification.never_timeout()); |
| 289 EXPECT_DOUBLE_EQ(kNotificationTimestamp, | 283 EXPECT_DOUBLE_EQ(kNotificationTimestamp, |
| 290 all_options_notification.timestamp().ToJsTime()); | 284 all_options_notification.timestamp().ToJsTime()); |
| 291 EXPECT_EQ(1u, all_options_notification.buttons().size()); | 285 EXPECT_EQ(1u, all_options_notification.buttons().size()); |
| 292 EXPECT_EQ("actionTitle", | 286 EXPECT_EQ("actionTitle", |
| 293 base::UTF16ToUTF8(all_options_notification.buttons()[0].title)); | 287 base::UTF16ToUTF8(all_options_notification.buttons()[0].title)); |
| 294 EXPECT_FALSE(all_options_notification.buttons()[0].icon.IsEmpty()); | 288 EXPECT_FALSE(all_options_notification.buttons()[0].icon.IsEmpty()); |
| 295 EXPECT_EQ(kIconWidth, all_options_notification.buttons()[0].icon.Width()); | 289 EXPECT_EQ(kIconWidth, all_options_notification.buttons()[0].icon.Width()); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); | 485 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); |
| 492 | 486 |
| 493 notification.delegate()->ButtonClick(0); | 487 notification.delegate()->ButtonClick(0); |
| 494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 488 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 495 EXPECT_EQ("action_button_click actionId1", script_result); | 489 EXPECT_EQ("action_button_click actionId1", script_result); |
| 496 | 490 |
| 497 notification.delegate()->ButtonClick(1); | 491 notification.delegate()->ButtonClick(1); |
| 498 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 492 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 499 EXPECT_EQ("action_button_click actionId2", script_result); | 493 EXPECT_EQ("action_button_click actionId2", script_result); |
| 500 } | 494 } |
| OLD | NEW |