Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / media / router / issue_unittest.cc
blob0c26bd6aa1dd5580fc610c789bf9aa7157d906a4
1 // Copyright 2015 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.
5 #include "chrome/browser/media/router/issue.h"
6 #include "chrome/grit/generated_resources.h"
7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "ui/base/l10n/l10n_util.h"
10 namespace media_router {
12 // Checks static IssueAction factory method.
13 TEST(IssueUnitTest, IssueActionConstructor) {
14 // Pre-defined "Ok" issue action.
15 IssueAction action1(IssueAction::TYPE_OK);
16 EXPECT_EQ(IssueAction::TYPE_OK, action1.type());
18 // Pre-defined "Cancel" issue action.
19 IssueAction action2(IssueAction::TYPE_CANCEL);
20 EXPECT_EQ(IssueAction::TYPE_CANCEL, action2.type());
23 // Tests custom Issue factory method without any secondary actions.
24 TEST(IssueUnitTest, CustomIssueConstructionWithNoSecondaryActions) {
25 std::vector<IssueAction> secondary_actions;
26 std::string title = "title";
27 std::string message = "message";
29 Issue issue1(title, message, IssueAction(IssueAction::TYPE_OK),
30 secondary_actions, "", Issue::WARNING, false,
31 "http://www.google.com/");
33 EXPECT_EQ(title, issue1.title());
34 EXPECT_EQ(message, issue1.message());
35 EXPECT_EQ(IssueAction::TYPE_OK, issue1.default_action().type());
36 EXPECT_TRUE(issue1.secondary_actions().empty());
37 EXPECT_EQ(Issue::WARNING, issue1.severity());
38 EXPECT_EQ("", issue1.route_id());
39 EXPECT_TRUE(issue1.is_global());
40 EXPECT_FALSE(issue1.is_blocking());
41 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
43 Issue issue2(title, message, IssueAction(IssueAction::TYPE_OK),
44 secondary_actions, "routeid", Issue::FATAL, true,
45 "http://www.google.com/");
47 EXPECT_EQ(title, issue2.title());
48 EXPECT_EQ(message, issue2.message());
49 EXPECT_EQ(IssueAction::TYPE_OK, issue1.default_action().type());
50 EXPECT_TRUE(issue2.secondary_actions().empty());
51 EXPECT_EQ(Issue::FATAL, issue2.severity());
52 EXPECT_EQ("routeid", issue2.route_id());
53 EXPECT_FALSE(issue2.is_global());
54 EXPECT_TRUE(issue2.is_blocking());
55 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
57 Issue issue3(title, "", IssueAction(IssueAction::TYPE_OK), secondary_actions,
58 "routeid", Issue::FATAL, true, "http://www.google.com/");
60 EXPECT_EQ(title, issue3.title());
61 EXPECT_EQ("", issue3.message());
62 EXPECT_EQ(IssueAction::TYPE_OK, issue1.default_action().type());
63 EXPECT_TRUE(issue3.secondary_actions().empty());
64 EXPECT_EQ(Issue::FATAL, issue3.severity());
65 EXPECT_EQ("routeid", issue3.route_id());
66 EXPECT_FALSE(issue3.is_global());
67 EXPECT_TRUE(issue3.is_blocking());
68 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
71 // Tests custom Issue factory method with secondary actions.
72 TEST(IssueUnitTest, CustomIssueConstructionWithSecondaryActions) {
73 std::vector<IssueAction> secondary_actions;
74 secondary_actions.push_back(IssueAction(IssueAction::TYPE_DISMISS));
75 secondary_actions.push_back(IssueAction(IssueAction::TYPE_CANCEL));
76 EXPECT_EQ(2u, secondary_actions.size());
77 std::string title = "title";
78 std::string message = "message";
80 Issue issue1(title, message, IssueAction(IssueAction::TYPE_OK),
81 secondary_actions, "", Issue::WARNING, false, "");
83 EXPECT_EQ(title, issue1.title());
84 EXPECT_EQ(message, issue1.message());
85 EXPECT_EQ(IssueAction::TYPE_OK, issue1.default_action().type());
86 EXPECT_FALSE(issue1.secondary_actions().empty());
87 EXPECT_EQ(2u, issue1.secondary_actions().size());
88 EXPECT_EQ(Issue::WARNING, issue1.severity());
89 EXPECT_EQ("", issue1.route_id());
90 EXPECT_TRUE(issue1.is_global());
91 EXPECT_FALSE(issue1.is_blocking());
93 Issue issue2(title, message, IssueAction(IssueAction::TYPE_OK),
94 secondary_actions, "routeid", Issue::FATAL, true, "");
96 EXPECT_EQ(title, issue2.title());
97 EXPECT_EQ(message, issue2.message());
98 EXPECT_EQ(IssueAction::TYPE_OK, issue2.default_action().type());
99 EXPECT_FALSE(issue2.secondary_actions().empty());
100 EXPECT_EQ(2u, issue2.secondary_actions().size());
101 EXPECT_EQ(Issue::FATAL, issue2.severity());
102 EXPECT_EQ("routeid", issue2.route_id());
103 EXPECT_FALSE(issue2.is_global());
104 EXPECT_TRUE(issue2.is_blocking());
106 Issue issue3(title, "", IssueAction(IssueAction::TYPE_OK), secondary_actions,
107 "routeid", Issue::FATAL, true, "");
109 EXPECT_EQ(title, issue3.title());
110 EXPECT_EQ("", issue3.message());
111 EXPECT_EQ(IssueAction::TYPE_OK, issue3.default_action().type());
112 EXPECT_FALSE(issue3.secondary_actions().empty());
113 EXPECT_EQ(2u, issue3.secondary_actions().size());
114 EXPECT_EQ(Issue::FATAL, issue3.severity());
115 EXPECT_EQ("routeid", issue3.route_id());
116 EXPECT_FALSE(issue3.is_global());
117 EXPECT_TRUE(issue3.is_blocking());
120 // Tests == and != method.
121 TEST(IssueUnitTest, Equal) {
122 std::vector<IssueAction> secondary_actions;
123 secondary_actions.push_back(IssueAction(IssueAction::TYPE_DISMISS));
124 secondary_actions.push_back(IssueAction(IssueAction::TYPE_CANCEL));
126 std::vector<IssueAction> secondary_actions2;
127 secondary_actions2.push_back(IssueAction(IssueAction::TYPE_DISMISS));
129 std::string title = "title";
130 std::string message = "message";
132 Issue issue1(Issue(title, message, IssueAction(IssueAction::TYPE_OK),
133 secondary_actions, "", Issue::WARNING, false, ""));
134 EXPECT_TRUE(issue1.Equals(issue1));
136 Issue issue2(Issue(title, message, IssueAction(IssueAction::TYPE_OK),
137 secondary_actions, "", Issue::WARNING, false, ""));
138 EXPECT_FALSE(issue1.Equals(issue2));
141 } // namespace media_router