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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/TopActivityListener.java

Issue 2969143002: Fixes redirects to external apps when navigating from PWA. (Closed)
Patch Set: Fix Created 3 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/TopActivityListener.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/TopActivityListener.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/TopActivityListener.java
deleted file mode 100644
index e746f7ef9e885cf561e4b790229c33aee216002c..0000000000000000000000000000000000000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/TopActivityListener.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.webapps;
-
-import android.app.Activity;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import org.chromium.base.ActivityState;
-import org.chromium.base.ApplicationStatus;
-import org.chromium.base.ApplicationStatus.ActivityStateListener;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
-
-import javax.annotation.Nullable;
-
-/**
- * Test rule tracking which Chrome activity is currently at the top of the task.
- */
-public class TopActivityListener implements TestRule {
- private final ActivityStateListener mListener = new ActivityStateListener() {
- @Override
- public void onActivityStateChange(Activity activity, int newState) {
- if (newState == ActivityState.RESUMED) {
- mMostRecentActivity = activity;
- }
- }
- };
-
- private Activity mMostRecentActivity;
-
- @Override
- public Statement apply(final Statement base, Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- ApplicationStatus.registerStateListenerForAllActivities(mListener);
- base.evaluate();
- ApplicationStatus.unregisterActivityStateListener(mListener);
- }
- };
- }
-
- @Nullable
- public Activity getMostRecentActivity() {
- return mMostRecentActivity;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Activity> T waitFor(final Class<T> expectedActivityClass) {
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mMostRecentActivity != null
- && expectedActivityClass.isAssignableFrom(mMostRecentActivity.getClass());
- }
- });
- return (T) mMostRecentActivity;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698