| 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 package org.chromium.chrome.browser.document; | 5 package org.chromium.chrome.browser.document; |
| 6 | 6 |
| 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 8 |
| 7 import android.annotation.SuppressLint; | 9 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 10 import android.app.Activity; |
| 9 import android.content.Context; | 11 import android.content.Context; |
| 10 import android.content.Intent; | 12 import android.content.Intent; |
| 11 import android.net.Uri; | 13 import android.net.Uri; |
| 12 import android.os.Parcel; | 14 import android.os.Parcel; |
| 13 import android.os.Parcelable; | 15 import android.os.Parcelable; |
| 14 import android.test.suitebuilder.annotation.SmallTest; | 16 import android.test.suitebuilder.annotation.SmallTest; |
| 15 | 17 |
| 16 import org.chromium.base.ApplicationState; | 18 import org.chromium.base.ApplicationState; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 import java.util.concurrent.atomic.AtomicReference; | 29 import java.util.concurrent.atomic.AtomicReference; |
| 28 | 30 |
| 29 | 31 |
| 30 /** | 32 /** |
| 31 * Tests for launching Chrome. | 33 * Tests for launching Chrome. |
| 32 */ | 34 */ |
| 33 @RetryOnFailure | 35 @RetryOnFailure |
| 34 public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActiv
ity> { | 36 public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActiv
ity> { |
| 35 | 37 |
| 36 private Context mContext; | 38 private Context mContext; |
| 39 private static final long DEVICE_STARTUP_TIMEOUT_MS = scaleTimeout(15000); |
| 37 | 40 |
| 38 public LauncherActivityTest() { | 41 public LauncherActivityTest() { |
| 39 super(ChromeActivity.class); | 42 super(ChromeActivity.class); |
| 40 } | 43 } |
| 41 | 44 |
| 42 @Override | 45 @Override |
| 43 public void setUp() throws Exception { | 46 public void setUp() throws Exception { |
| 44 super.setUp(); | 47 super.setUp(); |
| 45 mContext = getInstrumentation().getTargetContext(); | 48 mContext = getInstrumentation().getTargetContext(); |
| 46 } | 49 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 CriteriaHelper.pollInstrumentationThread( | 98 CriteriaHelper.pollInstrumentationThread( |
| 96 new Criteria("ChromeLauncherActivity did not start Chrome") { | 99 new Criteria("ChromeLauncherActivity did not start Chrome") { |
| 97 @Override | 100 @Override |
| 98 public boolean isSatisfied() { | 101 public boolean isSatisfied() { |
| 99 final List<WeakReference<Activity>> references = | 102 final List<WeakReference<Activity>> references = |
| 100 ApplicationStatus.getRunningActivities(); | 103 ApplicationStatus.getRunningActivities(); |
| 101 if (references.size() != 1) return false; | 104 if (references.size() != 1) return false; |
| 102 launchedActivity.set(references.get(0).get()); | 105 launchedActivity.set(references.get(0).get()); |
| 103 return launchedActivity.get() instanceof ChromeActivity; | 106 return launchedActivity.get() instanceof ChromeActivity; |
| 104 } | 107 } |
| 105 }); | 108 }, DEVICE_STARTUP_TIMEOUT_MS, CriteriaHelper.DEFAULT_POLLING_INT
ERVAL); |
| 106 return launchedActivity.get(); | 109 return launchedActivity.get(); |
| 107 } | 110 } |
| 108 | 111 |
| 109 @Override | 112 @Override |
| 110 public void startMainActivity() throws InterruptedException { | 113 public void startMainActivity() throws InterruptedException { |
| 111 } | 114 } |
| 112 | 115 |
| 113 /** | 116 /** |
| 114 * This Parcelable does not adhere to the form standards of a well formed Pa
rcelable and will | 117 * This Parcelable does not adhere to the form standards of a well formed Pa
rcelable and will |
| 115 * thus cause a BadParcelableException. The lint suppression is needed sinc
e it detects that | 118 * thus cause a BadParcelableException. The lint suppression is needed sinc
e it detects that |
| 116 * this will throw a BadParcelableException. | 119 * this will throw a BadParcelableException. |
| 117 */ | 120 */ |
| 118 @SuppressLint("ParcelCreator") | 121 @SuppressLint("ParcelCreator") |
| 119 private static class InvalidParcelable implements Parcelable { | 122 private static class InvalidParcelable implements Parcelable { |
| 120 @Override | 123 @Override |
| 121 public void writeToParcel(Parcel parcel, int params) { | 124 public void writeToParcel(Parcel parcel, int params) { |
| 122 } | 125 } |
| 123 | 126 |
| 124 @Override | 127 @Override |
| 125 public int describeContents() { | 128 public int describeContents() { |
| 126 return 0; | 129 return 0; |
| 127 } | 130 } |
| 128 } | 131 } |
| 129 } | 132 } |
| OLD | NEW |