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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "chrome/browser/media/router/issues_observer.h" |
11 #include "chrome/browser/media/router/media_router.mojom.h" | 12 #include "chrome/browser/media/router/media_router.mojom.h" |
12 #include "chrome/browser/media/router/media_router_mojo_impl.h" | 13 #include "chrome/browser/media/router/media_router_mojo_impl.h" |
13 #include "chrome/browser/media/router/media_routes_observer.h" | 14 #include "chrome/browser/media/router/media_routes_observer.h" |
14 #include "chrome/browser/media/router/media_sinks_observer.h" | 15 #include "chrome/browser/media/router/media_sinks_observer.h" |
15 #include "extensions/browser/event_page_tracker.h" | 16 #include "extensions/browser/event_page_tracker.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 | 18 |
18 namespace media_router { | 19 namespace media_router { |
19 | 20 |
20 // Matcher for objects that uses Equals() member function for equality check. | 21 // Matcher for objects that uses Equals() member function for equality check. |
21 MATCHER_P(Equals, other, "") { | 22 MATCHER_P(Equals, other, "") { |
22 return arg.Equals(other); | 23 return arg.Equals(other); |
23 } | 24 } |
24 | 25 |
25 // Matcher for a sequence of objects that uses Equals() member function for | 26 // Matcher for a sequence of objects that uses Equals() member function for |
26 // equality check. | 27 // equality check. |
27 MATCHER_P(SequenceEquals, other, "") { | 28 MATCHER_P(SequenceEquals, other, "") { |
28 if (arg.size() != other.size()) { | 29 if (arg.size() != other.size()) { |
29 return false; | 30 return false; |
30 } | 31 } |
31 for (size_t i = 0; i < arg.size(); ++i) { | 32 for (size_t i = 0; i < arg.size(); ++i) { |
32 if (!arg[i].Equals(other[i])) { | 33 if (!arg[i].Equals(other[i])) { |
33 return false; | 34 return false; |
34 } | 35 } |
35 } | 36 } |
36 return true; | 37 return true; |
37 } | 38 } |
38 | 39 |
| 40 // Matcher for checking all fields in Issue objects except the ID. |
| 41 MATCHER_P(EqualsIssue, other, "") { |
| 42 if (arg.title() != other.title()) |
| 43 return false; |
| 44 |
| 45 if (arg.message() != other.message()) |
| 46 return false; |
| 47 |
| 48 if (!arg.default_action().Equals(other.default_action())) |
| 49 return false; |
| 50 |
| 51 if (arg.secondary_actions().size() != other.secondary_actions().size()) |
| 52 return false; |
| 53 |
| 54 for (size_t i = 0; i < arg.secondary_actions().size(); ++i) { |
| 55 if (!arg.secondary_actions()[i].Equals(other.secondary_actions()[i])) |
| 56 return false; |
| 57 } |
| 58 |
| 59 if (arg.route_id() != other.route_id()) |
| 60 return false; |
| 61 |
| 62 if (arg.severity() != other.severity()) |
| 63 return false; |
| 64 |
| 65 if (arg.is_blocking() != other.is_blocking()) |
| 66 return false; |
| 67 |
| 68 if (arg.help_url() != other.help_url()) |
| 69 return false; |
| 70 |
| 71 return true; |
| 72 } |
| 73 |
| 74 class MockIssuesObserver : public IssuesObserver { |
| 75 public: |
| 76 explicit MockIssuesObserver(MediaRouter* router); |
| 77 ~MockIssuesObserver() override; |
| 78 |
| 79 MOCK_METHOD1(OnIssueUpdated, void(const Issue* issue)); |
| 80 }; |
| 81 |
39 class MockMediaRouteProvider : public interfaces::MediaRouteProvider { | 82 class MockMediaRouteProvider : public interfaces::MediaRouteProvider { |
40 public: | 83 public: |
41 MockMediaRouteProvider(); | 84 MockMediaRouteProvider(); |
42 ~MockMediaRouteProvider() override; | 85 ~MockMediaRouteProvider() override; |
43 | 86 |
44 MOCK_METHOD6(CreateRoute, | 87 MOCK_METHOD6(CreateRoute, |
45 void(const mojo::String& source_urn, | 88 void(const mojo::String& source_urn, |
46 const mojo::String& sink_id, | 89 const mojo::String& sink_id, |
47 const mojo::String& presentation_id, | 90 const mojo::String& presentation_id, |
48 const mojo::String& origin, | 91 const mojo::String& origin, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 142 |
100 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id)); | 143 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id)); |
101 MOCK_METHOD2(WakeEventPage, | 144 MOCK_METHOD2(WakeEventPage, |
102 bool(const std::string& extension_id, | 145 bool(const std::string& extension_id, |
103 const base::Callback<void(bool)>& callback)); | 146 const base::Callback<void(bool)>& callback)); |
104 }; | 147 }; |
105 | 148 |
106 } // namespace media_router | 149 } // namespace media_router |
107 | 150 |
108 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 151 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
OLD | NEW |