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

Side by Side Diff: chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog_unittest.cc

Issue 2498223002: arc: enable use_new_wrapper_types for intent_helper.mojom (Closed)
Patch Set: rebase Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog .h" 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog .h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace arc { 10 namespace arc {
(...skipping 14 matching lines...) Expand all
25 if (!fallback_url.is_empty()) 25 if (!fallback_url.is_empty())
26 ptr->fallback_url = fallback_url.spec(); 26 ptr->fallback_url = fallback_url.spec();
27 return ptr; 27 return ptr;
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 // Tests that when no apps are returned from ARC, GetAction returns 32 // Tests that when no apps are returned from ARC, GetAction returns
33 // SHOW_CHROME_OS_DIALOG. 33 // SHOW_CHROME_OS_DIALOG.
34 TEST(ArcExternalProtocolDialogTest, TestGetActionWithNoApp) { 34 TEST(ArcExternalProtocolDialogTest, TestGetActionWithNoApp) {
35 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 35 std::vector<mojom::IntentHandlerInfoPtr> handlers;
36 std::pair<GURL, std::string> url_and_package; 36 std::pair<GURL, std::string> url_and_package;
37 EXPECT_EQ(GetActionResult::SHOW_CHROME_OS_DIALOG, 37 EXPECT_EQ(GetActionResult::SHOW_CHROME_OS_DIALOG,
38 GetActionForTesting(GURL("external-protocol:foo"), handlers, 38 GetActionForTesting(GURL("external-protocol:foo"), handlers,
39 handlers.size(), &url_and_package)); 39 handlers.size(), &url_and_package));
40 } 40 }
41 41
42 // Tests that when one app is passed to GetAction but the user hasn't selected 42 // Tests that when one app is passed to GetAction but the user hasn't selected
43 // it, the function returns ASK_USER. 43 // it, the function returns ASK_USER.
44 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneApp) { 44 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneApp) {
45 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 45 std::vector<mojom::IntentHandlerInfoPtr> handlers;
46 handlers.push_back( 46 handlers.push_back(
47 Create("package", "com.google.package.name", false, GURL())); 47 Create("package", "com.google.package.name", false, GURL()));
48 48
49 const size_t no_selection = handlers.size(); 49 const size_t no_selection = handlers.size();
50 std::pair<GURL, std::string> url_and_package; 50 std::pair<GURL, std::string> url_and_package;
51 EXPECT_EQ(GetActionResult::ASK_USER, 51 EXPECT_EQ(GetActionResult::ASK_USER,
52 GetActionForTesting(GURL("external-protocol:foo"), handlers, 52 GetActionForTesting(GURL("external-protocol:foo"), handlers,
53 no_selection, &url_and_package)); 53 no_selection, &url_and_package));
54 } 54 }
55 55
56 // Tests that when one preferred app is passed to GetAction, the function 56 // Tests that when one preferred app is passed to GetAction, the function
57 // returns HANDLE_URL_IN_ARC even if the user hasn't selected the app. 57 // returns HANDLE_URL_IN_ARC even if the user hasn't selected the app.
58 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOnePreferredApp) { 58 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOnePreferredApp) {
59 const GURL external_url("external-protocol:foo"); 59 const GURL external_url("external-protocol:foo");
60 const std::string package_name("com.google.package.name"); 60 const std::string package_name("com.google.package.name");
61 61
62 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 62 std::vector<mojom::IntentHandlerInfoPtr> handlers;
63 handlers.push_back(Create("package", package_name, true, GURL())); 63 handlers.push_back(Create("package", package_name, true, GURL()));
64 64
65 const size_t no_selection = handlers.size(); 65 const size_t no_selection = handlers.size();
66 std::pair<GURL, std::string> url_and_package; 66 std::pair<GURL, std::string> url_and_package;
67 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 67 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
68 GetActionForTesting(external_url, handlers, no_selection, 68 GetActionForTesting(external_url, handlers, no_selection,
69 &url_and_package)); 69 &url_and_package));
70 EXPECT_EQ(external_url, url_and_package.first); 70 EXPECT_EQ(external_url, url_and_package.first);
71 EXPECT_EQ(package_name, url_and_package.second); 71 EXPECT_EQ(package_name, url_and_package.second);
72 } 72 }
73 73
74 // Tests that when one app is passed to GetAction, the user has already selected 74 // Tests that when one app is passed to GetAction, the user has already selected
75 // it, the function returns HANDLE_URL_IN_ARC. 75 // it, the function returns HANDLE_URL_IN_ARC.
76 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneAppSelected) { 76 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneAppSelected) {
77 const GURL external_url("external-protocol:foo"); 77 const GURL external_url("external-protocol:foo");
78 const std::string package_name("com.google.package.name"); 78 const std::string package_name("com.google.package.name");
79 79
80 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 80 std::vector<mojom::IntentHandlerInfoPtr> handlers;
81 handlers.push_back(Create("package", package_name, false, GURL())); 81 handlers.push_back(Create("package", package_name, false, GURL()));
82 82
83 constexpr size_t kSelection = 0; 83 constexpr size_t kSelection = 0;
84 std::pair<GURL, std::string> url_and_package; 84 std::pair<GURL, std::string> url_and_package;
85 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 85 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
86 GetActionForTesting(external_url, handlers, kSelection, 86 GetActionForTesting(external_url, handlers, kSelection,
87 &url_and_package)); 87 &url_and_package));
88 EXPECT_EQ(external_url, url_and_package.first); 88 EXPECT_EQ(external_url, url_and_package.first);
89 EXPECT_EQ(package_name, url_and_package.second); 89 EXPECT_EQ(package_name, url_and_package.second);
90 } 90 }
91 91
92 // Tests the same as TestGetActionWithOnePreferredApp but with two apps. 92 // Tests the same as TestGetActionWithOnePreferredApp but with two apps.
93 TEST(ArcExternalProtocolDialogTest, 93 TEST(ArcExternalProtocolDialogTest,
94 TestGetActionWithOnePreferredAppAndOneOther) { 94 TestGetActionWithOnePreferredAppAndOneOther) {
95 const GURL external_url("external-protocol:foo"); 95 const GURL external_url("external-protocol:foo");
96 const std::string package_name("com.google.package2.name"); 96 const std::string package_name("com.google.package2.name");
97 97
98 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 98 std::vector<mojom::IntentHandlerInfoPtr> handlers;
99 handlers.push_back( 99 handlers.push_back(
100 Create("package", "com.google.package.name", false, GURL())); 100 Create("package", "com.google.package.name", false, GURL()));
101 handlers.push_back(Create("package2", package_name, true, GURL())); 101 handlers.push_back(Create("package2", package_name, true, GURL()));
102 102
103 const size_t no_selection = handlers.size(); 103 const size_t no_selection = handlers.size();
104 std::pair<GURL, std::string> url_and_package; 104 std::pair<GURL, std::string> url_and_package;
105 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 105 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
106 GetActionForTesting(external_url, handlers, no_selection, 106 GetActionForTesting(external_url, handlers, no_selection,
107 &url_and_package)); 107 &url_and_package));
108 EXPECT_EQ(external_url, url_and_package.first); 108 EXPECT_EQ(external_url, url_and_package.first);
109 EXPECT_EQ(package_name, url_and_package.second); 109 EXPECT_EQ(package_name, url_and_package.second);
110 } 110 }
111 111
112 // Tests that HANDLE_URL_IN_ARC is returned for geo: URL. The URL is special in 112 // Tests that HANDLE_URL_IN_ARC is returned for geo: URL. The URL is special in
113 // that intent_helper (i.e. the Chrome proxy) can handle it but Chrome cannot. 113 // that intent_helper (i.e. the Chrome proxy) can handle it but Chrome cannot.
114 // We have to send such a URL to intent_helper to let the helper rewrite the 114 // We have to send such a URL to intent_helper to let the helper rewrite the
115 // URL to https://maps.google.com/?latlon=xxx which Chrome can handle. 115 // URL to https://maps.google.com/?latlon=xxx which Chrome can handle.
116 TEST(ArcExternalProtocolDialogTest, TestGetActionWithGeoUrl) { 116 TEST(ArcExternalProtocolDialogTest, TestGetActionWithGeoUrl) {
117 const GURL geo_url("geo:37.7749,-122.4194"); 117 const GURL geo_url("geo:37.7749,-122.4194");
118 118
119 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 119 std::vector<mojom::IntentHandlerInfoPtr> handlers;
120 handlers.push_back(Create("Chrome", kChromePackageName, true, GURL())); 120 handlers.push_back(Create("Chrome", kChromePackageName, true, GURL()));
121 121
122 const size_t no_selection = handlers.size(); 122 const size_t no_selection = handlers.size();
123 std::pair<GURL, std::string> url_and_package; 123 std::pair<GURL, std::string> url_and_package;
124 EXPECT_EQ( 124 EXPECT_EQ(
125 GetActionResult::HANDLE_URL_IN_ARC, 125 GetActionResult::HANDLE_URL_IN_ARC,
126 GetActionForTesting(geo_url, handlers, no_selection, &url_and_package)); 126 GetActionForTesting(geo_url, handlers, no_selection, &url_and_package));
127 EXPECT_EQ(geo_url, url_and_package.first); 127 EXPECT_EQ(geo_url, url_and_package.first);
128 EXPECT_EQ(kChromePackageName, url_and_package.second); 128 EXPECT_EQ(kChromePackageName, url_and_package.second);
129 } 129 }
130 130
131 // Tests that OPEN_URL_IN_CHROME is returned when a handler with a fallback http 131 // Tests that OPEN_URL_IN_CHROME is returned when a handler with a fallback http
132 // URL and kChromePackageName is passed to GetAction, even if the handler is not 132 // URL and kChromePackageName is passed to GetAction, even if the handler is not
133 // a preferred one. 133 // a preferred one.
134 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneFallbackUrl) { 134 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneFallbackUrl) {
135 const GURL intent_url_with_fallback( 135 const GURL intent_url_with_fallback(
136 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 136 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
137 "S.browser_fallback_url=http://zxing.org;end"); 137 "S.browser_fallback_url=http://zxing.org;end");
138 const GURL fallback_url("http://zxing.org"); 138 const GURL fallback_url("http://zxing.org");
139 139
140 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 140 std::vector<mojom::IntentHandlerInfoPtr> handlers;
141 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url)); 141 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url));
142 142
143 const size_t no_selection = handlers.size(); 143 const size_t no_selection = handlers.size();
144 std::pair<GURL, std::string> url_and_package; 144 std::pair<GURL, std::string> url_and_package;
145 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME, 145 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME,
146 GetActionForTesting(intent_url_with_fallback, handlers, 146 GetActionForTesting(intent_url_with_fallback, handlers,
147 no_selection, &url_and_package)); 147 no_selection, &url_and_package));
148 EXPECT_EQ(fallback_url, url_and_package.first); 148 EXPECT_EQ(fallback_url, url_and_package.first);
149 EXPECT_EQ(kChromePackageName, url_and_package.second); 149 EXPECT_EQ(kChromePackageName, url_and_package.second);
150 } 150 }
151 151
152 // Tests the same with https and is_preferred == true. 152 // Tests the same with https and is_preferred == true.
153 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOnePreferredFallbackUrl) { 153 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOnePreferredFallbackUrl) {
154 const GURL intent_url_with_fallback( 154 const GURL intent_url_with_fallback(
155 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 155 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
156 "S.browser_fallback_url=https://zxing.org;end"); 156 "S.browser_fallback_url=https://zxing.org;end");
157 const GURL fallback_url("https://zxing.org"); 157 const GURL fallback_url("https://zxing.org");
158 158
159 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 159 std::vector<mojom::IntentHandlerInfoPtr> handlers;
160 handlers.push_back(Create("Chrome", kChromePackageName, true, fallback_url)); 160 handlers.push_back(Create("Chrome", kChromePackageName, true, fallback_url));
161 161
162 const size_t no_selection = handlers.size(); 162 const size_t no_selection = handlers.size();
163 std::pair<GURL, std::string> url_and_package; 163 std::pair<GURL, std::string> url_and_package;
164 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME, 164 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME,
165 GetActionForTesting(intent_url_with_fallback, handlers, 165 GetActionForTesting(intent_url_with_fallback, handlers,
166 no_selection, &url_and_package)); 166 no_selection, &url_and_package));
167 EXPECT_EQ(fallback_url, url_and_package.first); 167 EXPECT_EQ(fallback_url, url_and_package.first);
168 EXPECT_EQ(kChromePackageName, url_and_package.second); 168 EXPECT_EQ(kChromePackageName, url_and_package.second);
169 } 169 }
170 170
171 // Tests that ASK_USER is returned when two handlers with fallback URLs are 171 // Tests that ASK_USER is returned when two handlers with fallback URLs are
172 // passed to GetAction. This may happen when the user has installed a 3rd party 172 // passed to GetAction. This may happen when the user has installed a 3rd party
173 // browser app, and then clicks a intent: URI with a http fallback. 173 // browser app, and then clicks a intent: URI with a http fallback.
174 TEST(ArcExternalProtocolDialogTest, TestGetActionWithTwoFallbackUrls) { 174 TEST(ArcExternalProtocolDialogTest, TestGetActionWithTwoFallbackUrls) {
175 const GURL intent_url_with_fallback( 175 const GURL intent_url_with_fallback(
176 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 176 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
177 "S.browser_fallback_url=http://zxing.org;end"); 177 "S.browser_fallback_url=http://zxing.org;end");
178 const GURL fallback_url("http://zxing.org"); 178 const GURL fallback_url("http://zxing.org");
179 179
180 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 180 std::vector<mojom::IntentHandlerInfoPtr> handlers;
181 handlers.push_back( 181 handlers.push_back(
182 Create("Other browser", "com.other.browser", false, fallback_url)); 182 Create("Other browser", "com.other.browser", false, fallback_url));
183 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url)); 183 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url));
184 184
185 const size_t no_selection = handlers.size(); 185 const size_t no_selection = handlers.size();
186 std::pair<GURL, std::string> url_and_package; 186 std::pair<GURL, std::string> url_and_package;
187 EXPECT_EQ(GetActionResult::ASK_USER, 187 EXPECT_EQ(GetActionResult::ASK_USER,
188 GetActionForTesting(intent_url_with_fallback, handlers, 188 GetActionForTesting(intent_url_with_fallback, handlers,
189 no_selection, &url_and_package)); 189 no_selection, &url_and_package));
190 } 190 }
191 191
192 // Tests the same but set Chrome as a preferred app. In this case, ASK_USER 192 // Tests the same but set Chrome as a preferred app. In this case, ASK_USER
193 // shouldn't be returned. 193 // shouldn't be returned.
194 TEST(ArcExternalProtocolDialogTest, 194 TEST(ArcExternalProtocolDialogTest,
195 TestGetActionWithTwoFallbackUrlsChromePreferred) { 195 TestGetActionWithTwoFallbackUrlsChromePreferred) {
196 const GURL intent_url_with_fallback( 196 const GURL intent_url_with_fallback(
197 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 197 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
198 "S.browser_fallback_url=http://zxing.org;end"); 198 "S.browser_fallback_url=http://zxing.org;end");
199 const GURL fallback_url("http://zxing.org"); 199 const GURL fallback_url("http://zxing.org");
200 200
201 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 201 std::vector<mojom::IntentHandlerInfoPtr> handlers;
202 handlers.push_back( 202 handlers.push_back(
203 Create("Other browser", "com.other.browser", false, fallback_url)); 203 Create("Other browser", "com.other.browser", false, fallback_url));
204 handlers.push_back(Create("Chrome", kChromePackageName, true, fallback_url)); 204 handlers.push_back(Create("Chrome", kChromePackageName, true, fallback_url));
205 205
206 const size_t no_selection = handlers.size(); 206 const size_t no_selection = handlers.size();
207 std::pair<GURL, std::string> url_and_package; 207 std::pair<GURL, std::string> url_and_package;
208 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME, 208 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME,
209 GetActionForTesting(intent_url_with_fallback, handlers, 209 GetActionForTesting(intent_url_with_fallback, handlers,
210 no_selection, &url_and_package)); 210 no_selection, &url_and_package));
211 EXPECT_EQ(fallback_url, url_and_package.first); 211 EXPECT_EQ(fallback_url, url_and_package.first);
212 EXPECT_EQ(kChromePackageName, url_and_package.second); 212 EXPECT_EQ(kChromePackageName, url_and_package.second);
213 } 213 }
214 214
215 // Tests the same but set "other browser" as a preferred app. In this case, 215 // Tests the same but set "other browser" as a preferred app. In this case,
216 // ASK_USER shouldn't be returned either. 216 // ASK_USER shouldn't be returned either.
217 TEST(ArcExternalProtocolDialogTest, 217 TEST(ArcExternalProtocolDialogTest,
218 TestGetActionWithTwoFallbackUrlsOtherBrowserPreferred) { 218 TestGetActionWithTwoFallbackUrlsOtherBrowserPreferred) {
219 const GURL intent_url_with_fallback( 219 const GURL intent_url_with_fallback(
220 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 220 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
221 "S.browser_fallback_url=http://zxing.org;end"); 221 "S.browser_fallback_url=http://zxing.org;end");
222 const GURL fallback_url("http://zxing.org"); 222 const GURL fallback_url("http://zxing.org");
223 const std::string package_name = "com.other.browser"; 223 const std::string package_name = "com.other.browser";
224 224
225 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 225 std::vector<mojom::IntentHandlerInfoPtr> handlers;
226 handlers.push_back(Create("Other browser", package_name, true, fallback_url)); 226 handlers.push_back(Create("Other browser", package_name, true, fallback_url));
227 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url)); 227 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url));
228 228
229 const size_t no_selection = handlers.size(); 229 const size_t no_selection = handlers.size();
230 std::pair<GURL, std::string> url_and_package; 230 std::pair<GURL, std::string> url_and_package;
231 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 231 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
232 GetActionForTesting(intent_url_with_fallback, handlers, 232 GetActionForTesting(intent_url_with_fallback, handlers,
233 no_selection, &url_and_package)); 233 no_selection, &url_and_package));
234 EXPECT_EQ(fallback_url, url_and_package.first); 234 EXPECT_EQ(fallback_url, url_and_package.first);
235 EXPECT_EQ(package_name, url_and_package.second); 235 EXPECT_EQ(package_name, url_and_package.second);
236 } 236 }
237 237
238 // Tests the same but set Chrome as a user-selected app. 238 // Tests the same but set Chrome as a user-selected app.
239 TEST(ArcExternalProtocolDialogTest, 239 TEST(ArcExternalProtocolDialogTest,
240 TestGetActionWithTwoFallbackUrlsChromeSelected) { 240 TestGetActionWithTwoFallbackUrlsChromeSelected) {
241 const GURL intent_url_with_fallback( 241 const GURL intent_url_with_fallback(
242 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 242 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
243 "S.browser_fallback_url=http://zxing.org;end"); 243 "S.browser_fallback_url=http://zxing.org;end");
244 const GURL fallback_url("http://zxing.org"); 244 const GURL fallback_url("http://zxing.org");
245 245
246 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 246 std::vector<mojom::IntentHandlerInfoPtr> handlers;
247 handlers.push_back( 247 handlers.push_back(
248 Create("Other browser", "com.other.browser", false, fallback_url)); 248 Create("Other browser", "com.other.browser", false, fallback_url));
249 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url)); 249 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url));
250 250
251 constexpr size_t kSelection = 1; // Chrome 251 constexpr size_t kSelection = 1; // Chrome
252 std::pair<GURL, std::string> url_and_package; 252 std::pair<GURL, std::string> url_and_package;
253 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME, 253 EXPECT_EQ(GetActionResult::OPEN_URL_IN_CHROME,
254 GetActionForTesting(intent_url_with_fallback, handlers, kSelection, 254 GetActionForTesting(intent_url_with_fallback, handlers, kSelection,
255 &url_and_package)); 255 &url_and_package));
256 EXPECT_EQ(fallback_url, url_and_package.first); 256 EXPECT_EQ(fallback_url, url_and_package.first);
257 EXPECT_EQ(kChromePackageName, url_and_package.second); 257 EXPECT_EQ(kChromePackageName, url_and_package.second);
258 } 258 }
259 259
260 // Tests the same but set "other browser" as a preferred app. 260 // Tests the same but set "other browser" as a preferred app.
261 TEST(ArcExternalProtocolDialogTest, 261 TEST(ArcExternalProtocolDialogTest,
262 TestGetActionWithTwoFallbackUrlsOtherBrowserSelected) { 262 TestGetActionWithTwoFallbackUrlsOtherBrowserSelected) {
263 const GURL intent_url_with_fallback( 263 const GURL intent_url_with_fallback(
264 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 264 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
265 "S.browser_fallback_url=http://zxing.org;end"); 265 "S.browser_fallback_url=http://zxing.org;end");
266 const GURL fallback_url("http://zxing.org"); 266 const GURL fallback_url("http://zxing.org");
267 const std::string package_name = "com.other.browser"; 267 const std::string package_name = "com.other.browser";
268 268
269 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 269 std::vector<mojom::IntentHandlerInfoPtr> handlers;
270 handlers.push_back( 270 handlers.push_back(
271 Create("Other browser", package_name, false, fallback_url)); 271 Create("Other browser", package_name, false, fallback_url));
272 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url)); 272 handlers.push_back(Create("Chrome", kChromePackageName, false, fallback_url));
273 273
274 constexpr size_t kSelection = 0; // the other browser 274 constexpr size_t kSelection = 0; // the other browser
275 std::pair<GURL, std::string> url_and_package; 275 std::pair<GURL, std::string> url_and_package;
276 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 276 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
277 GetActionForTesting(intent_url_with_fallback, handlers, kSelection, 277 GetActionForTesting(intent_url_with_fallback, handlers, kSelection,
278 &url_and_package)); 278 &url_and_package));
279 EXPECT_EQ(fallback_url, url_and_package.first); 279 EXPECT_EQ(fallback_url, url_and_package.first);
280 EXPECT_EQ(package_name, url_and_package.second); 280 EXPECT_EQ(package_name, url_and_package.second);
281 } 281 }
282 282
283 // Tests that ASK_USER is returned when a handler with a fallback market: URL 283 // Tests that ASK_USER is returned when a handler with a fallback market: URL
284 // is passed to GetAction. 284 // is passed to GetAction.
285 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneMarketFallbackUrl) { 285 TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneMarketFallbackUrl) {
286 const GURL intent_url_with_fallback( 286 const GURL intent_url_with_fallback(
287 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 287 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
288 const GURL fallback_url("market://details?id=com.google.abc"); 288 const GURL fallback_url("market://details?id=com.google.abc");
289 289
290 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 290 std::vector<mojom::IntentHandlerInfoPtr> handlers;
291 handlers.push_back( 291 handlers.push_back(
292 Create("Play Store", "com.google.play.store", false, fallback_url)); 292 Create("Play Store", "com.google.play.store", false, fallback_url));
293 293
294 const size_t no_selection = handlers.size(); 294 const size_t no_selection = handlers.size();
295 std::pair<GURL, std::string> url_and_package; 295 std::pair<GURL, std::string> url_and_package;
296 EXPECT_EQ(GetActionResult::ASK_USER, 296 EXPECT_EQ(GetActionResult::ASK_USER,
297 GetActionForTesting(intent_url_with_fallback, handlers, 297 GetActionForTesting(intent_url_with_fallback, handlers,
298 no_selection, &url_and_package)); 298 no_selection, &url_and_package));
299 } 299 }
300 300
301 // Tests the same but with is_preferred == true. 301 // Tests the same but with is_preferred == true.
302 TEST(ArcExternalProtocolDialogTest, 302 TEST(ArcExternalProtocolDialogTest,
303 TestGetActionWithOnePreferredMarketFallbackUrl) { 303 TestGetActionWithOnePreferredMarketFallbackUrl) {
304 const GURL intent_url_with_fallback( 304 const GURL intent_url_with_fallback(
305 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 305 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
306 const GURL fallback_url("market://details?id=com.google.abc"); 306 const GURL fallback_url("market://details?id=com.google.abc");
307 const std::string play_store_package_name = "com.google.play.store"; 307 const std::string play_store_package_name = "com.google.play.store";
308 308
309 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 309 std::vector<mojom::IntentHandlerInfoPtr> handlers;
310 handlers.push_back( 310 handlers.push_back(
311 Create("Play Store", play_store_package_name, true, fallback_url)); 311 Create("Play Store", play_store_package_name, true, fallback_url));
312 312
313 const size_t no_selection = handlers.size(); 313 const size_t no_selection = handlers.size();
314 std::pair<GURL, std::string> url_and_package; 314 std::pair<GURL, std::string> url_and_package;
315 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 315 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
316 GetActionForTesting(intent_url_with_fallback, handlers, 316 GetActionForTesting(intent_url_with_fallback, handlers,
317 no_selection, &url_and_package)); 317 no_selection, &url_and_package));
318 EXPECT_EQ(fallback_url, url_and_package.first); 318 EXPECT_EQ(fallback_url, url_and_package.first);
319 EXPECT_EQ(play_store_package_name, url_and_package.second); 319 EXPECT_EQ(play_store_package_name, url_and_package.second);
320 } 320 }
321 321
322 // Tests the same but with an app_seleteced_index. 322 // Tests the same but with an app_seleteced_index.
323 TEST(ArcExternalProtocolDialogTest, 323 TEST(ArcExternalProtocolDialogTest,
324 TestGetActionWithOneSelectedMarketFallbackUrl) { 324 TestGetActionWithOneSelectedMarketFallbackUrl) {
325 const GURL intent_url_with_fallback( 325 const GURL intent_url_with_fallback(
326 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 326 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
327 const GURL fallback_url("market://details?id=com.google.abc"); 327 const GURL fallback_url("market://details?id=com.google.abc");
328 const std::string play_store_package_name = "com.google.play.store"; 328 const std::string play_store_package_name = "com.google.play.store";
329 329
330 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 330 std::vector<mojom::IntentHandlerInfoPtr> handlers;
331 handlers.push_back( 331 handlers.push_back(
332 Create("Play Store", play_store_package_name, false, fallback_url)); 332 Create("Play Store", play_store_package_name, false, fallback_url));
333 333
334 constexpr size_t kSelection = 0; 334 constexpr size_t kSelection = 0;
335 std::pair<GURL, std::string> url_and_package; 335 std::pair<GURL, std::string> url_and_package;
336 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 336 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
337 GetActionForTesting(intent_url_with_fallback, handlers, kSelection, 337 GetActionForTesting(intent_url_with_fallback, handlers, kSelection,
338 &url_and_package)); 338 &url_and_package));
339 EXPECT_EQ(fallback_url, url_and_package.first); 339 EXPECT_EQ(fallback_url, url_and_package.first);
340 EXPECT_EQ(play_store_package_name, url_and_package.second); 340 EXPECT_EQ(play_store_package_name, url_and_package.second);
341 } 341 }
342 342
343 // Tests that ASK_USER is returned when two handlers with fallback market: URLs 343 // Tests that ASK_USER is returned when two handlers with fallback market: URLs
344 // are passed to GetAction. Unlike the two browsers case, this rarely happens on 344 // are passed to GetAction. Unlike the two browsers case, this rarely happens on
345 // the user's device, though. 345 // the user's device, though.
346 TEST(ArcExternalProtocolDialogTest, TestGetActionWithTwoMarketFallbackUrls) { 346 TEST(ArcExternalProtocolDialogTest, TestGetActionWithTwoMarketFallbackUrls) {
347 const GURL intent_url_with_fallback( 347 const GURL intent_url_with_fallback(
348 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 348 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
349 const GURL fallback_url("market://details?id=com.google.abc"); 349 const GURL fallback_url("market://details?id=com.google.abc");
350 350
351 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 351 std::vector<mojom::IntentHandlerInfoPtr> handlers;
352 handlers.push_back( 352 handlers.push_back(
353 Create("Play Store", "com.google.play.store", false, fallback_url)); 353 Create("Play Store", "com.google.play.store", false, fallback_url));
354 handlers.push_back( 354 handlers.push_back(
355 Create("Other Store app", "com.other.play.store", false, fallback_url)); 355 Create("Other Store app", "com.other.play.store", false, fallback_url));
356 356
357 const size_t no_selection = handlers.size(); 357 const size_t no_selection = handlers.size();
358 std::pair<GURL, std::string> url_and_package; 358 std::pair<GURL, std::string> url_and_package;
359 EXPECT_EQ(GetActionResult::ASK_USER, 359 EXPECT_EQ(GetActionResult::ASK_USER,
360 GetActionForTesting(intent_url_with_fallback, handlers, 360 GetActionForTesting(intent_url_with_fallback, handlers,
361 no_selection, &url_and_package)); 361 no_selection, &url_and_package));
362 } 362 }
363 363
364 // Tests the same, but make the second handler a preferred one. 364 // Tests the same, but make the second handler a preferred one.
365 TEST(ArcExternalProtocolDialogTest, 365 TEST(ArcExternalProtocolDialogTest,
366 TestGetActionWithTwoMarketFallbackUrlsOnePreferred) { 366 TestGetActionWithTwoMarketFallbackUrlsOnePreferred) {
367 const GURL intent_url_with_fallback( 367 const GURL intent_url_with_fallback(
368 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 368 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
369 const GURL fallback_url("market://details?id=com.google.abc"); 369 const GURL fallback_url("market://details?id=com.google.abc");
370 const std::string play_store_package_name = "com.google.play.store"; 370 const std::string play_store_package_name = "com.google.play.store";
371 371
372 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 372 std::vector<mojom::IntentHandlerInfoPtr> handlers;
373 handlers.push_back( 373 handlers.push_back(
374 Create("Other Store app", "com.other.play.store", false, fallback_url)); 374 Create("Other Store app", "com.other.play.store", false, fallback_url));
375 handlers.push_back( 375 handlers.push_back(
376 Create("Play Store", play_store_package_name, true, fallback_url)); 376 Create("Play Store", play_store_package_name, true, fallback_url));
377 377
378 const size_t no_selection = handlers.size(); 378 const size_t no_selection = handlers.size();
379 std::pair<GURL, std::string> url_and_package; 379 std::pair<GURL, std::string> url_and_package;
380 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 380 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
381 GetActionForTesting(intent_url_with_fallback, handlers, 381 GetActionForTesting(intent_url_with_fallback, handlers,
382 no_selection, &url_and_package)); 382 no_selection, &url_and_package));
383 EXPECT_EQ(fallback_url, url_and_package.first); 383 EXPECT_EQ(fallback_url, url_and_package.first);
384 EXPECT_EQ(play_store_package_name, url_and_package.second); 384 EXPECT_EQ(play_store_package_name, url_and_package.second);
385 } 385 }
386 386
387 // Tests the same, but make the second handler a selected one. 387 // Tests the same, but make the second handler a selected one.
388 TEST(ArcExternalProtocolDialogTest, 388 TEST(ArcExternalProtocolDialogTest,
389 TestGetActionWithTwoMarketFallbackUrlsOneSelected) { 389 TestGetActionWithTwoMarketFallbackUrlsOneSelected) {
390 const GURL intent_url_with_fallback( 390 const GURL intent_url_with_fallback(
391 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end"); 391 "intent://scan/#Intent;scheme=abc;package=com.google.abc;end");
392 const GURL fallback_url("market://details?id=com.google.abc"); 392 const GURL fallback_url("market://details?id=com.google.abc");
393 const std::string play_store_package_name = "com.google.play.store"; 393 const std::string play_store_package_name = "com.google.play.store";
394 394
395 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 395 std::vector<mojom::IntentHandlerInfoPtr> handlers;
396 handlers.push_back( 396 handlers.push_back(
397 Create("Other Store app", "com.other.play.store", false, fallback_url)); 397 Create("Other Store app", "com.other.play.store", false, fallback_url));
398 handlers.push_back( 398 handlers.push_back(
399 Create("Play Store", play_store_package_name, false, fallback_url)); 399 Create("Play Store", play_store_package_name, false, fallback_url));
400 400
401 const size_t kSelection = 1; // Play Store 401 const size_t kSelection = 1; // Play Store
402 std::pair<GURL, std::string> url_and_package; 402 std::pair<GURL, std::string> url_and_package;
403 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 403 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
404 GetActionForTesting(intent_url_with_fallback, handlers, kSelection, 404 GetActionForTesting(intent_url_with_fallback, handlers, kSelection,
405 &url_and_package)); 405 &url_and_package));
406 EXPECT_EQ(fallback_url, url_and_package.first); 406 EXPECT_EQ(fallback_url, url_and_package.first);
407 EXPECT_EQ(play_store_package_name, url_and_package.second); 407 EXPECT_EQ(play_store_package_name, url_and_package.second);
408 } 408 }
409 409
410 // Tests the case where geo: URL is returned as a fallback. This should never 410 // Tests the case where geo: URL is returned as a fallback. This should never
411 // happen because intent_helper ignores such a fallback, but just in case. 411 // happen because intent_helper ignores such a fallback, but just in case.
412 // GetAction shouldn't crash at least. 412 // GetAction shouldn't crash at least.
413 TEST(ArcExternalProtocolDialogTest, TestGetActionWithGeoUrlAsFallback) { 413 TEST(ArcExternalProtocolDialogTest, TestGetActionWithGeoUrlAsFallback) {
414 // Note: geo: as a browser fallback is banned in the production code. 414 // Note: geo: as a browser fallback is banned in the production code.
415 const GURL intent_url_with_fallback( 415 const GURL intent_url_with_fallback(
416 "intent://scan/#Intent;scheme=abc;package=com.google.abc;" 416 "intent://scan/#Intent;scheme=abc;package=com.google.abc;"
417 "S.browser_fallback_url=geo:37.7749,-122.4194;end"); 417 "S.browser_fallback_url=geo:37.7749,-122.4194;end");
418 const GURL geo_url("geo:37.7749,-122.4194"); 418 const GURL geo_url("geo:37.7749,-122.4194");
419 419
420 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 420 std::vector<mojom::IntentHandlerInfoPtr> handlers;
421 handlers.push_back(Create("Chrome", kChromePackageName, true, geo_url)); 421 handlers.push_back(Create("Chrome", kChromePackageName, true, geo_url));
422 422
423 const size_t no_selection = handlers.size(); 423 const size_t no_selection = handlers.size();
424 std::pair<GURL, std::string> url_and_package; 424 std::pair<GURL, std::string> url_and_package;
425 // GetAction shouldn't return OPEN_URL_IN_CHROME because Chrome doesn't 425 // GetAction shouldn't return OPEN_URL_IN_CHROME because Chrome doesn't
426 // directly support geo:. 426 // directly support geo:.
427 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC, 427 EXPECT_EQ(GetActionResult::HANDLE_URL_IN_ARC,
428 GetActionForTesting(intent_url_with_fallback, handlers, 428 GetActionForTesting(intent_url_with_fallback, handlers,
429 no_selection, &url_and_package)); 429 no_selection, &url_and_package));
430 EXPECT_EQ(geo_url, url_and_package.first); 430 EXPECT_EQ(geo_url, url_and_package.first);
(...skipping 10 matching lines...) Expand all
441 EXPECT_TRUE(ShouldIgnoreNavigationForTesting(ui::PageTransitionFromInt( 441 EXPECT_TRUE(ShouldIgnoreNavigationForTesting(ui::PageTransitionFromInt(
442 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT | 442 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT |
443 ui::PAGE_TRANSITION_HOME_PAGE))); 443 ui::PAGE_TRANSITION_HOME_PAGE)));
444 EXPECT_TRUE(ShouldIgnoreNavigationForTesting(ui::PageTransitionFromInt( 444 EXPECT_TRUE(ShouldIgnoreNavigationForTesting(ui::PageTransitionFromInt(
445 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_HOME_PAGE))); 445 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_HOME_PAGE)));
446 } 446 }
447 447
448 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers| 448 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers|
449 // is empty. 449 // is empty.
450 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateEmpty) { 450 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateEmpty) {
451 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 451 std::vector<mojom::IntentHandlerInfoPtr> handlers;
452 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers)); 452 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers));
453 } 453 }
454 454
455 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers| 455 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers|
456 // only contains a (non-Chrome) app. 456 // only contains a (non-Chrome) app.
457 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateAppOnly) { 457 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateAppOnly) {
458 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 458 std::vector<mojom::IntentHandlerInfoPtr> handlers;
459 // On production, when |handlers| only contains app(s), the fallback field is 459 // On production, when |handlers| only contains app(s), the fallback field is
460 // empty, but to make the test more reliable, use non-empty fallback URL. 460 // empty, but to make the test more reliable, use non-empty fallback URL.
461 handlers.push_back( 461 handlers.push_back(
462 Create("App", "app.package", false, GURL("http://www"))); 462 Create("App", "app.package", false, GURL("http://www")));
463 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers)); 463 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers));
464 } 464 }
465 465
466 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers| 466 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers|
467 // only contains (non-Chrome) apps. 467 // only contains (non-Chrome) apps.
468 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateAppsOnly) { 468 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateAppsOnly) {
469 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 469 std::vector<mojom::IntentHandlerInfoPtr> handlers;
470 // On production, when |handlers| only contains app(s), the fallback field is 470 // On production, when |handlers| only contains app(s), the fallback field is
471 // empty, but to make the test more reliable, use non-empty fallback URL. 471 // empty, but to make the test more reliable, use non-empty fallback URL.
472 handlers.push_back( 472 handlers.push_back(
473 Create("App1", "app1.package", false, GURL("http://www"))); 473 Create("App1", "app1.package", false, GURL("http://www")));
474 handlers.push_back( 474 handlers.push_back(
475 Create("App2", "app2.package", false, GURL("http://www"))); 475 Create("App2", "app2.package", false, GURL("http://www")));
476 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers)); 476 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers));
477 } 477 }
478 478
479 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers| 479 // Test that GetUrlToNavigateOnDeactivate returns an empty GURL when |handlers|
480 // contains Chrome, but it's not for http(s). 480 // contains Chrome, but it's not for http(s).
481 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateGeoUrl) { 481 TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateGeoUrl) {
482 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 482 std::vector<mojom::IntentHandlerInfoPtr> handlers;
483 handlers.push_back(Create("Chrome", kChromePackageName, false, 483 handlers.push_back(Create("Chrome", kChromePackageName, false,
484 GURL("geo:37.4220,-122.0840"))); 484 GURL("geo:37.4220,-122.0840")));
485 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers)); 485 EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers));
486 } 486 }
487 487
488 // Test that GetUrlToNavigateOnDeactivate returns non-empty GURL when |handlers| 488 // Test that GetUrlToNavigateOnDeactivate returns non-empty GURL when |handlers|
489 // contains Chrome and an app. 489 // contains Chrome and an app.
490 TEST(ArcExternalProtocolDialogTest, 490 TEST(ArcExternalProtocolDialogTest,
491 TestGetUrlToNavigateOnDeactivateChromeAndApp) { 491 TestGetUrlToNavigateOnDeactivateChromeAndApp) {
492 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 492 std::vector<mojom::IntentHandlerInfoPtr> handlers;
493 // On production, all handlers have the same fallback URL, but to make sure 493 // On production, all handlers have the same fallback URL, but to make sure
494 // that "Chrome" is actually selected by the function, use different URLs. 494 // that "Chrome" is actually selected by the function, use different URLs.
495 handlers.push_back(Create("A browser app", "browser.app.package", false, 495 handlers.push_back(Create("A browser app", "browser.app.package", false,
496 GURL("http://www1/"))); 496 GURL("http://www1/")));
497 handlers.push_back( 497 handlers.push_back(
498 Create("Chrome", kChromePackageName, false, GURL("http://www2/"))); 498 Create("Chrome", kChromePackageName, false, GURL("http://www2/")));
499 handlers.push_back(Create("Yet another browser app", 499 handlers.push_back(Create("Yet another browser app",
500 "yet.another.browser.app.package", false, 500 "yet.another.browser.app.package", false,
501 GURL("http://www3/"))); 501 GURL("http://www3/")));
502 502
503 EXPECT_EQ(GURL("http://www2/"), 503 EXPECT_EQ(GURL("http://www2/"),
504 GetUrlToNavigateOnDeactivateForTesting(handlers)); 504 GetUrlToNavigateOnDeactivateForTesting(handlers));
505 } 505 }
506 506
507 // Does the same with https, just in case. 507 // Does the same with https, just in case.
508 TEST(ArcExternalProtocolDialogTest, 508 TEST(ArcExternalProtocolDialogTest,
509 TestGetUrlToNavigateOnDeactivateChromeAndAppHttps) { 509 TestGetUrlToNavigateOnDeactivateChromeAndAppHttps) {
510 mojo::Array<mojom::IntentHandlerInfoPtr> handlers; 510 std::vector<mojom::IntentHandlerInfoPtr> handlers;
511 handlers.push_back(Create("A browser app", "browser.app.package", false, 511 handlers.push_back(Create("A browser app", "browser.app.package", false,
512 GURL("https://www1/"))); 512 GURL("https://www1/")));
513 handlers.push_back( 513 handlers.push_back(
514 Create("Chrome", kChromePackageName, false, GURL("https://www2/"))); 514 Create("Chrome", kChromePackageName, false, GURL("https://www2/")));
515 handlers.push_back(Create("Yet another browser app", 515 handlers.push_back(Create("Yet another browser app",
516 "yet.another.browser.app.package", false, 516 "yet.another.browser.app.package", false,
517 GURL("https://www3/"))); 517 GURL("https://www3/")));
518 518
519 EXPECT_EQ(GURL("https://www2/"), 519 EXPECT_EQ(GURL("https://www2/"),
520 GetUrlToNavigateOnDeactivateForTesting(handlers)); 520 GetUrlToNavigateOnDeactivateForTesting(handlers));
521 } 521 }
522 522
523 } // namespace arc 523 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698