OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
9 import android.util.Pair; | 9 import android.util.Pair; |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 contentViewCore.getWebContents().setNavigationTransitionDelegate(delegat
e); | 119 contentViewCore.getWebContents().setNavigationTransitionDelegate(delegat
e); |
120 | 120 |
121 loadUrl(contentViewCore.getWebContents().getNavigationController(), | 121 loadUrl(contentViewCore.getWebContents().getNavigationController(), |
122 testCallbackHelperContainer, new LoadUrlParams(URL_1)); | 122 testCallbackHelperContainer, new LoadUrlParams(URL_1)); |
123 | 123 |
124 assertTrue("didDeferAfterResponseStarted called.", delegate.getDidCallDe
fer()); | 124 assertTrue("didDeferAfterResponseStarted called.", delegate.getDidCallDe
fer()); |
125 } | 125 } |
126 | 126 |
127 /** | 127 /** |
128 * Tests that the listener does not receive DidDeferAfterResponseStarted if
we specify that | 128 * Tests that the listener does not receive DidDeferAfterResponseStarted if
we specify that |
129 * the transition is handled. | 129 * the transition is not handled. |
130 */ | 130 */ |
131 @SmallTest | 131 @SmallTest |
132 public void testDidDeferAfterResponseStartedNotCalled() throws Throwable { | 132 public void testDidDeferAfterResponseStartedNotCalled() throws Throwable { |
133 ContentShellActivity activity = launchContentShellWithUrl(URL_1); | 133 ContentShellActivity activity = launchContentShellWithUrl(URL_1); |
134 waitForActiveShellToBeDoneLoading(); | 134 waitForActiveShellToBeDoneLoading(); |
135 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); | 135 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); |
136 TestCallbackHelperContainer testCallbackHelperContainer = | 136 TestCallbackHelperContainer testCallbackHelperContainer = |
137 new TestCallbackHelperContainer(contentViewCore); | 137 new TestCallbackHelperContainer(contentViewCore); |
138 | 138 |
139 contentViewCore.getWebContents().setHasPendingNavigationTransitionForTes
ting(); | 139 contentViewCore.getWebContents().setHasPendingNavigationTransitionForTes
ting(); |
140 TestNavigationTransitionDelegate delegate = new TestNavigationTransition
Delegate( | 140 TestNavigationTransitionDelegate delegate = new TestNavigationTransition
Delegate( |
141 contentViewCore.getWebContents(), | 141 contentViewCore.getWebContents(), |
142 false); | 142 false); |
143 contentViewCore.getWebContents().setNavigationTransitionDelegate(delegat
e); | 143 contentViewCore.getWebContents().setNavigationTransitionDelegate(delegat
e); |
144 | 144 |
145 loadUrl(contentViewCore.getWebContents().getNavigationController(), | 145 loadUrl(contentViewCore.getWebContents().getNavigationController(), |
146 testCallbackHelperContainer, new LoadUrlParams(URL_1)); | 146 testCallbackHelperContainer, new LoadUrlParams(URL_1)); |
147 | 147 |
148 assertFalse("didDeferAfterResponseStarted called.", delegate.getDidCallD
efer()); | 148 assertFalse("didDeferAfterResponseStarted called.", delegate.getDidCallD
efer()); |
149 } | 149 } |
150 | 150 |
151 /** | 151 /** |
| 152 * Tests clearNavigationTransitionData(). The listener does not receive |
| 153 * DidDeferAfterResponseStarted even if we specify that the transition is ha
ndled |
| 154 * because the data is cleared before the navigation. |
| 155 */ |
| 156 @SmallTest |
| 157 public void testDidDeferAfterResponseStartedNotCalledWithoutData() throws Th
rowable { |
| 158 ContentShellActivity activity = launchContentShellWithUrl(URL_1); |
| 159 waitForActiveShellToBeDoneLoading(); |
| 160 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); |
| 161 TestCallbackHelperContainer testCallbackHelperContainer = |
| 162 new TestCallbackHelperContainer(contentViewCore); |
| 163 |
| 164 contentViewCore.getWebContents().setHasPendingNavigationTransitionForTes
ting(); |
| 165 TestNavigationTransitionDelegate delegate = new TestNavigationTransition
Delegate( |
| 166 contentViewCore.getWebContents(), |
| 167 true); |
| 168 contentViewCore.getWebContents().setNavigationTransitionDelegate(delegat
e); |
| 169 |
| 170 contentViewCore.getWebContents().clearNavigationTransitionData(); |
| 171 loadUrl(contentViewCore.getWebContents().getNavigationController(), |
| 172 testCallbackHelperContainer, new LoadUrlParams(URL_1)); |
| 173 |
| 174 assertFalse("didDeferAfterResponseStarted called.", delegate.getDidCallD
efer()); |
| 175 } |
| 176 |
| 177 /** |
152 * Tests that the resource handler doesn't query the listener if no transiti
on is pending. | 178 * Tests that the resource handler doesn't query the listener if no transiti
on is pending. |
153 */ | 179 */ |
154 @SmallTest | 180 @SmallTest |
155 public void testWillHandleDeferAfterResponseStartedNotCalled() throws Throwa
ble { | 181 public void testWillHandleDeferAfterResponseStartedNotCalled() throws Throwa
ble { |
156 ContentShellActivity activity = launchContentShellWithUrl(URL_1); | 182 ContentShellActivity activity = launchContentShellWithUrl(URL_1); |
157 waitForActiveShellToBeDoneLoading(); | 183 waitForActiveShellToBeDoneLoading(); |
158 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); | 184 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); |
159 TestCallbackHelperContainer testCallbackHelperContainer = | 185 TestCallbackHelperContainer testCallbackHelperContainer = |
160 new TestCallbackHelperContainer(contentViewCore); | 186 new TestCallbackHelperContainer(contentViewCore); |
161 | 187 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 329 |
304 assertTrue("X-Transition-Entering-Color parsed correctly.", | 330 assertTrue("X-Transition-Entering-Color parsed correctly.", |
305 TextUtils.equals( | 331 TextUtils.equals( |
306 delegate.getTransitionEnteringColor(), | 332 delegate.getTransitionEnteringColor(), |
307 transitionEnteringColor)); | 333 transitionEnteringColor)); |
308 } finally { | 334 } finally { |
309 webServer.shutdown(); | 335 webServer.shutdown(); |
310 } | 336 } |
311 } | 337 } |
312 } | 338 } |
OLD | NEW |