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

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

Issue 2458073003: Modifies how Arc's throttle handles redirections (Closed)
Patch Set: Removing redirected_to_arc_ flag 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" 7 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h"
8 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 8 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 EXPECT_FALSE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( 56 EXPECT_FALSE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting(
57 GURL("http://a.google.com/"), GURL())); 57 GURL("http://a.google.com/"), GURL()));
58 EXPECT_FALSE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( 58 EXPECT_FALSE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting(
59 GURL(), GURL())); 59 GURL(), GURL()));
60 60
61 // A navigation not within the same domain can be overridden. 61 // A navigation not within the same domain can be overridden.
62 EXPECT_TRUE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( 62 EXPECT_TRUE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting(
63 GURL("http://www.google.com"), GURL("http://www.not-google.com/"))); 63 GURL("http://www.google.com"), GURL("http://www.not-google.com/")));
64 EXPECT_TRUE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( 64 EXPECT_TRUE(ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting(
65 GURL("http://www.not-google.com"), GURL("http://www.google.com/"))); 65 GURL("http://www.not-google.com"), GURL("http://www.google.com/")));
66
67 // A navigation with neither an http nor https scheme cannot be overriden.
Yusuke Sato 2016/10/31 20:26:51 Thanks!
68 EXPECT_FALSE(GURL("chrome-extension://fake_document"),
69 GURL("http://www.a.com"));
70 EXPECT_FALSE(GURL("http://www.a.com"),
71 GURL("chrome-extension://fake_document"));
72 EXPECT_FALSE(GURL("chrome-extension://fake_document"),
73 GURL("https://www.a.com"));
74 EXPECT_FALSE(GURL("https://www.a.com"),
75 GURL("chrome-extension://fake_document"));
76 EXPECT_FALSE(GURL("chrome-extension://fake_a"),
77 GURL("chrome-extension://fake_b"));
66 } 78 }
67 79
68 TEST(ArcNavigationThrottleTest, TestIsAppAvailable) { 80 TEST(ArcNavigationThrottleTest, TestIsAppAvailable) {
69 // Test an empty array. 81 // Test an empty array.
70 EXPECT_FALSE( 82 EXPECT_FALSE(
71 ArcNavigationThrottle::IsAppAvailableForTesting(CreateArray(0, 0))); 83 ArcNavigationThrottle::IsAppAvailableForTesting(CreateArray(0, 0)));
72 // Chrome only. 84 // Chrome only.
73 EXPECT_FALSE( 85 EXPECT_FALSE(
74 ArcNavigationThrottle::IsAppAvailableForTesting(CreateArray(1, 0))); 86 ArcNavigationThrottle::IsAppAvailableForTesting(CreateArray(1, 0)));
75 // Chrome and another app. 87 // Chrome and another app.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for (size_t i = 0; i <= ArcNavigationThrottle::kMaxAppResults * 2; ++i) { 189 for (size_t i = 0; i <= ArcNavigationThrottle::kMaxAppResults * 2; ++i) {
178 // When Chrome does not exist in |handlers|, swap is unnecessary. 190 // When Chrome does not exist in |handlers|, swap is unnecessary.
179 mojo::Array<mojom::IntentHandlerInfoPtr> handlers = CreateArray(i, i); 191 mojo::Array<mojom::IntentHandlerInfoPtr> handlers = CreateArray(i, i);
180 EXPECT_FALSE(ArcNavigationThrottle::IsSwapElementsNeededForTesting( 192 EXPECT_FALSE(ArcNavigationThrottle::IsSwapElementsNeededForTesting(
181 handlers, &indices)) 193 handlers, &indices))
182 << i; 194 << i;
183 } 195 }
184 } 196 }
185 197
186 } // namespace arc 198 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698