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 "content/renderer/manifest/manifest_parser.h" | 5 #include "content/renderer/manifest/manifest_parser.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/public/common/manifest.h" | 8 #include "content/public/common/manifest.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 // Some invalid width/height combinations. | 574 // Some invalid width/height combinations. |
575 { | 575 { |
576 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," | 576 Manifest manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\"," |
577 "\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }"); | 577 "\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }"); |
578 gfx::Size any = gfx::Size(0, 0); | 578 gfx::Size any = gfx::Size(0, 0); |
579 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); | 579 EXPECT_EQ(manifest.icons[0].sizes.size(), 0u); |
580 } | 580 } |
581 } | 581 } |
582 | 582 |
| 583 TEST_F(ManifestParserTest, GCMSenderIDParseRules) { |
| 584 // Smoke test. |
| 585 { |
| 586 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }"); |
| 587 EXPECT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
| 588 } |
| 589 |
| 590 // Trim whitespaces. |
| 591 { |
| 592 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }"); |
| 593 EXPECT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
| 594 } |
| 595 |
| 596 // Don't parse if property isn't a string. |
| 597 { |
| 598 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }"); |
| 599 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); |
| 600 } |
| 601 { |
| 602 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); |
| 603 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); |
| 604 } |
| 605 } |
| 606 |
583 } // namespace content | 607 } // namespace content |
OLD | NEW |