OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.externalnav; |
| 6 |
| 7 import android.content.Intent; |
| 8 import android.net.Uri; |
| 9 import android.test.InstrumentationTestCase; |
| 10 import android.test.suitebuilder.annotation.SmallTest; |
| 11 |
| 12 /** |
| 13 * Instrumentation tests for {@link IntentWithGesturesHandler}. |
| 14 */ |
| 15 public class IntentWithGesturesHandlerTest extends InstrumentationTestCase { |
| 16 |
| 17 @Override |
| 18 public void tearDown() throws Exception { |
| 19 IntentWithGesturesHandler.getInstance().clear(); |
| 20 super.tearDown(); |
| 21 } |
| 22 |
| 23 @SmallTest |
| 24 public void testCanUseGestureTokenOnlyOnce() { |
| 25 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://abc"
)); |
| 26 IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(intent); |
| 27 assertTrue(intent.hasExtra(IntentWithGesturesHandler.EXTRA_USER_GESTURE_
TOKEN)); |
| 28 assertTrue(IntentWithGesturesHandler.getInstance().getUserGestureAndClea
r(intent)); |
| 29 assertFalse(IntentWithGesturesHandler.getInstance().getUserGestureAndCle
ar(intent)); |
| 30 } |
| 31 |
| 32 @SmallTest |
| 33 public void testModifiedGestureToken() { |
| 34 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://abc"
)); |
| 35 IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(intent); |
| 36 intent.setData(Uri.parse("content://xyz")); |
| 37 assertFalse(IntentWithGesturesHandler.getInstance().getUserGestureAndCle
ar(intent)); |
| 38 } |
| 39 |
| 40 @SmallTest |
| 41 public void testPreviousGestureToken() { |
| 42 Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("content://abc
")); |
| 43 IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(intent1); |
| 44 Intent intent2 = new Intent(Intent.ACTION_VIEW, Uri.parse("content://xyz
")); |
| 45 IntentWithGesturesHandler.getInstance().onNewIntentWithGesture(intent2); |
| 46 assertFalse(IntentWithGesturesHandler.getInstance().getUserGestureAndCle
ar(intent1)); |
| 47 } |
| 48 } |
OLD | NEW |