Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / media / router / issue_unittest.cc
blob19d2bd3403ab0f8de1f276a41d68f5ab2355a365
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::OK);
16 EXPECT_EQ(IssueAction::OK, action1.type());
18 // Pre-defined "Cancel" issue action.
19 IssueAction action2(IssueAction::CANCEL);
20 EXPECT_EQ(IssueAction::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::OK), secondary_actions,
30 "", Issue::WARNING, false, "http://www.google.com/");
32 EXPECT_EQ(title, issue1.title());
33 EXPECT_EQ(message, issue1.message());
34 EXPECT_EQ(IssueAction::OK, issue1.default_action().type());
35 EXPECT_TRUE(issue1.secondary_actions().empty());
36 EXPECT_EQ(Issue::WARNING, issue1.severity());
37 EXPECT_EQ("", issue1.route_id());
38 EXPECT_TRUE(issue1.is_global());
39 EXPECT_FALSE(issue1.is_blocking());
40 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
42 Issue issue2(title, message, IssueAction(IssueAction::OK), secondary_actions,
43 "routeid", Issue::FATAL, true, "http://www.google.com/");
45 EXPECT_EQ(title, issue2.title());
46 EXPECT_EQ(message, issue2.message());
47 EXPECT_EQ(IssueAction::OK, issue1.default_action().type());
48 EXPECT_TRUE(issue2.secondary_actions().empty());
49 EXPECT_EQ(Issue::FATAL, issue2.severity());
50 EXPECT_EQ("routeid", issue2.route_id());
51 EXPECT_FALSE(issue2.is_global());
52 EXPECT_TRUE(issue2.is_blocking());
53 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
55 Issue issue3(title, "", IssueAction(IssueAction::OK), secondary_actions,
56 "routeid", Issue::FATAL, true, "http://www.google.com/");
58 EXPECT_EQ(title, issue3.title());
59 EXPECT_EQ("", issue3.message());
60 EXPECT_EQ(IssueAction::OK, issue1.default_action().type());
61 EXPECT_TRUE(issue3.secondary_actions().empty());
62 EXPECT_EQ(Issue::FATAL, issue3.severity());
63 EXPECT_EQ("routeid", issue3.route_id());
64 EXPECT_FALSE(issue3.is_global());
65 EXPECT_TRUE(issue3.is_blocking());
66 EXPECT_EQ("http://www.google.com/", issue1.help_url().spec());
69 // Tests custom Issue factory method with secondary actions.
70 TEST(IssueUnitTest, CustomIssueConstructionWithSecondaryActions) {
71 std::vector<IssueAction> secondary_actions;
72 secondary_actions.push_back(IssueAction(IssueAction::DISMISS));
73 secondary_actions.push_back(IssueAction(IssueAction::CANCEL));
74 EXPECT_EQ(2u, secondary_actions.size());
75 std::string title = "title";
76 std::string message = "message";
78 Issue issue1(title, message, IssueAction(IssueAction::OK), secondary_actions,
79 "", Issue::WARNING, false, "");
81 EXPECT_EQ(title, issue1.title());
82 EXPECT_EQ(message, issue1.message());
83 EXPECT_EQ(IssueAction::OK, issue1.default_action().type());
84 EXPECT_FALSE(issue1.secondary_actions().empty());
85 EXPECT_EQ(2u, issue1.secondary_actions().size());
86 EXPECT_EQ(Issue::WARNING, issue1.severity());
87 EXPECT_EQ("", issue1.route_id());
88 EXPECT_TRUE(issue1.is_global());
89 EXPECT_FALSE(issue1.is_blocking());
91 Issue issue2(title, message, IssueAction(IssueAction::OK), secondary_actions,
92 "routeid", Issue::FATAL, true, "");
94 EXPECT_EQ(title, issue2.title());
95 EXPECT_EQ(message, issue2.message());
96 EXPECT_EQ(IssueAction::OK, issue2.default_action().type());
97 EXPECT_FALSE(issue2.secondary_actions().empty());
98 EXPECT_EQ(2u, issue2.secondary_actions().size());
99 EXPECT_EQ(Issue::FATAL, issue2.severity());
100 EXPECT_EQ("routeid", issue2.route_id());
101 EXPECT_FALSE(issue2.is_global());
102 EXPECT_TRUE(issue2.is_blocking());
104 Issue issue3(title, "", IssueAction(IssueAction::OK), secondary_actions,
105 "routeid", Issue::FATAL, true, "");
107 EXPECT_EQ(title, issue3.title());
108 EXPECT_EQ("", issue3.message());
109 EXPECT_EQ(IssueAction::OK, issue3.default_action().type());
110 EXPECT_FALSE(issue3.secondary_actions().empty());
111 EXPECT_EQ(2u, issue3.secondary_actions().size());
112 EXPECT_EQ(Issue::FATAL, issue3.severity());
113 EXPECT_EQ("routeid", issue3.route_id());
114 EXPECT_FALSE(issue3.is_global());
115 EXPECT_TRUE(issue3.is_blocking());
118 // Tests == and != method.
119 TEST(IssueUnitTest, Equal) {
120 std::vector<IssueAction> secondary_actions;
121 secondary_actions.push_back(IssueAction(IssueAction::DISMISS));
122 secondary_actions.push_back(IssueAction(IssueAction::CANCEL));
124 std::vector<IssueAction> secondary_actions2;
125 secondary_actions2.push_back(IssueAction(IssueAction::DISMISS));
127 std::string title = "title";
128 std::string message = "message";
130 Issue issue1(Issue(title, message, IssueAction(IssueAction::OK),
131 secondary_actions, "", Issue::WARNING, false, ""));
132 EXPECT_TRUE(issue1.Equals(issue1));
134 Issue issue2(Issue(title, message, IssueAction(IssueAction::OK),
135 secondary_actions, "", Issue::WARNING, false, ""));
136 EXPECT_FALSE(issue1.Equals(issue2));
139 } // namespace media_router