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

Side by Side Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 550173002: Implement ManifestParser in content/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_fetcher
Patch Set: Created 6 years, 3 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
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/manifest/manifest_parser.h"
6
7 #include "base/strings/string_util.h"
8 #include "content/public/common/manifest.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace content {
12
13 TEST(ManifestParserTest, EmptyStringNull) {
14 Manifest manifest = ManifestParser::Parse("");
15
16 // A parsing error is equivalent to an empty manifest.
17 ASSERT_TRUE(manifest.IsEmpty());
18 ASSERT_TRUE(manifest.name.is_null());
19 ASSERT_TRUE(manifest.short_name.is_null());
20 }
21
22 TEST(ManifestParserTest, ValidNoContentParses) {
23 Manifest manifest = ManifestParser::Parse("{}");
24
25 // Check that all the fields are null in that case.
26 ASSERT_TRUE(manifest.IsEmpty());
27 ASSERT_TRUE(manifest.name.is_null());
28 ASSERT_TRUE(manifest.short_name.is_null());
29 }
30
31 TEST(ManifestParserTest, NameParseRules) {
32 // Smoke test.
33 {
34 Manifest manifest = ManifestParser::Parse("{ \"name\": \"foo\" }");
35 ASSERT_TRUE(EqualsASCII(manifest.name.string(), "foo"));
36 }
37
38 // Trim whitespaces.
39 {
40 Manifest manifest = ManifestParser::Parse("{ \"name\": \" foo \" }");
41 ASSERT_TRUE(EqualsASCII(manifest.name.string(), "foo"));
42 }
43
44 // Don't parse if name isn't a string.
45 {
46 Manifest manifest = ManifestParser::Parse("{ \"name\": {} }");
47 ASSERT_TRUE(manifest.name.is_null());
48 }
49
50 // Don't parse if name isn't a string.
51 {
52 Manifest manifest = ManifestParser::Parse("{ \"name\": 42 }");
53 ASSERT_TRUE(manifest.name.is_null());
54 }
55 }
56
57 TEST(ManifestParserTest, ShortNameParseRules) {
58 // Smoke test.
59 {
60 Manifest manifest = ManifestParser::Parse("{ \"short_name\": \"foo\" }");
61 ASSERT_TRUE(EqualsASCII(manifest.short_name.string(), "foo"));
62 }
63
64 // Trim whitespaces.
65 {
66 Manifest manifest =
67 ManifestParser::Parse("{ \"short_name\": \" foo \" }");
68 ASSERT_TRUE(EqualsASCII(manifest.short_name.string(), "foo"));
69 }
70
71 // Don't parse if name isn't a string.
72 {
73 Manifest manifest = ManifestParser::Parse("{ \"short_name\": {} }");
74 ASSERT_TRUE(manifest.short_name.is_null());
75 }
76
77 // Don't parse if name isn't a string.
78 {
79 Manifest manifest = ManifestParser::Parse("{ \"short_name\": 42 }");
80 ASSERT_TRUE(manifest.short_name.is_null());
81 }
82 }
83
84 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698