| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/media/router/issue_manager.h" | 9 #include "chrome/browser/media/router/issue_manager.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 | 12 |
| 13 namespace media_router { | 13 namespace media_router { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const char kTestRouteId[] = "routeId"; | 16 const char kTestRouteId[] = "routeId"; |
| 17 | 17 |
| 18 Issue CreateTestIssue(const std::string& route_id) { | 18 Issue CreateTestIssue(const std::string& route_id) { |
| 19 return Issue("title", "message", IssueAction(IssueAction::TYPE_DISMISS), | 19 Issue issue("title", Issue::ActionType::DISMISS, Issue::Severity::WARNING); |
| 20 std::vector<IssueAction>(), route_id, Issue::WARNING, false, | 20 issue.set_message("message"); |
| 21 12345); | 21 issue.set_route_id(route_id); |
| 22 issue.set_help_page_id(12345); |
| 23 return issue; |
| 22 } | 24 } |
| 23 | 25 |
| 24 class IssueManagerUnitTest : public ::testing::Test { | 26 class IssueManagerUnitTest : public ::testing::Test { |
| 25 protected: | 27 protected: |
| 26 IssueManagerUnitTest() {} | 28 IssueManagerUnitTest() {} |
| 27 ~IssueManagerUnitTest() override {} | 29 ~IssueManagerUnitTest() override {} |
| 28 | 30 |
| 29 content::TestBrowserThreadBundle thread_bundle_; | 31 content::TestBrowserThreadBundle thread_bundle_; |
| 30 IssueManager manager_; | 32 IssueManager manager_; |
| 31 | 33 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 // Attempt to add the same issue. Duplicates should not be inserted. | 50 // Attempt to add the same issue. Duplicates should not be inserted. |
| 49 manager_.AddIssue(issue); | 51 manager_.AddIssue(issue); |
| 50 EXPECT_EQ(1u, manager_.GetIssueCount()); | 52 EXPECT_EQ(1u, manager_.GetIssueCount()); |
| 51 } | 53 } |
| 52 | 54 |
| 53 TEST_F(IssueManagerUnitTest, ClearIssue) { | 55 TEST_F(IssueManagerUnitTest, ClearIssue) { |
| 54 Issue issue = CreateTestIssue(kTestRouteId); | 56 Issue issue = CreateTestIssue(kTestRouteId); |
| 55 | 57 |
| 56 // Remove an issue that doesn't exist. | 58 // Remove an issue that doesn't exist. |
| 57 manager_.ClearIssue("id"); | 59 manager_.ClearIssue(999); |
| 58 | 60 |
| 59 // Add initial issue. | 61 // Add initial issue. |
| 60 manager_.AddIssue(issue); | 62 manager_.AddIssue(issue); |
| 61 EXPECT_EQ(1u, manager_.GetIssueCount()); | 63 EXPECT_EQ(1u, manager_.GetIssueCount()); |
| 62 | 64 |
| 63 // Remove the only issue. | 65 // Remove the only issue. |
| 64 manager_.ClearIssue(issue.id()); | 66 manager_.ClearIssue(issue.id()); |
| 65 EXPECT_EQ(0u, manager_.GetIssueCount()); | 67 EXPECT_EQ(0u, manager_.GetIssueCount()); |
| 66 | 68 |
| 67 // Remove an issue that doesn't exist. | 69 // Remove an issue that doesn't exist. |
| 68 manager_.ClearIssue("id"); | 70 manager_.ClearIssue(999); |
| 69 EXPECT_EQ(0u, manager_.GetIssueCount()); | 71 EXPECT_EQ(0u, manager_.GetIssueCount()); |
| 70 } | 72 } |
| 71 | 73 |
| 72 TEST_F(IssueManagerUnitTest, ClearAllIssues) { | 74 TEST_F(IssueManagerUnitTest, ClearAllIssues) { |
| 73 // Add ten issues. | 75 // Add ten issues. |
| 74 for (int i = 0; i < 10; i++) { | 76 for (int i = 0; i < 10; i++) { |
| 75 manager_.AddIssue(CreateTestIssue(kTestRouteId)); | 77 manager_.AddIssue(CreateTestIssue(kTestRouteId)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 // Check that the issues were added. | 80 // Check that the issues were added. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 manager_.ClearIssuesWithRouteId(route_id_one); | 139 manager_.ClearIssuesWithRouteId(route_id_one); |
| 138 EXPECT_EQ(20u, manager_.GetIssueCount()); | 140 EXPECT_EQ(20u, manager_.GetIssueCount()); |
| 139 | 141 |
| 140 // Remove all routes with route_id_two. | 142 // Remove all routes with route_id_two. |
| 141 manager_.ClearIssuesWithRouteId(route_id_two); | 143 manager_.ClearIssuesWithRouteId(route_id_two); |
| 142 EXPECT_EQ(10u, manager_.GetIssueCount()); | 144 EXPECT_EQ(10u, manager_.GetIssueCount()); |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace | 147 } // namespace |
| 146 } // namespace media_router | 148 } // namespace media_router |
| OLD | NEW |