| Index: remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
|
| diff --git a/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java b/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c71de2fc77833d12d9a5d7ee3ac9e1b91af12c23
|
| --- /dev/null
|
| +++ b/remoting/android/java/src/org/chromium/chromoting/ConnectAndCancelTest.java
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2016 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.chromoting;
|
| +
|
| +import android.os.Handler;
|
| +import android.os.Looper;
|
| +
|
| +import org.chromium.base.Log;
|
| +import org.chromium.chromoting.jni.Client;
|
| +
|
| +public class ConnectAndCancelTest {
|
| + private static final String TAG = "Chromoting";
|
| + private static final long RETRY_DELAY_MSEC = 1000;
|
| + private static ConnectAndCancelTest sTest;
|
| + private boolean mConnectScheduled;
|
| + private int mConnectCount;
|
| +
|
| + private Chromoting mChromoting;
|
| +
|
| + private ConnectAndCancelTest() {
|
| + mConnectScheduled = false;
|
| + mConnectCount = 0;
|
| + }
|
| +
|
| + public static ConnectAndCancelTest getTest() {
|
| + if (sTest == null) {
|
| + sTest = new ConnectAndCancelTest();
|
| + }
|
| + return sTest;
|
| + }
|
| +
|
| + public void start(Chromoting chromoting) {
|
| + mChromoting = chromoting;
|
| + delayedConnect();
|
| + }
|
| +
|
| + public void onAuthDialog(Client client) {
|
| + client.destroy();
|
| + delayedConnect();
|
| + }
|
| +
|
| + private void delayedConnect() {
|
| + if (mConnectScheduled) {
|
| + return;
|
| + }
|
| + mConnectScheduled = true;
|
| + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + Log.d(TAG, "ConnectAndCancelTest connection count: %d", mConnectCount);
|
| + mConnectCount++;
|
| + mConnectScheduled = false;
|
| + mChromoting.onHostClicked(0);
|
| + }
|
| + }, RETRY_DELAY_MSEC);
|
| + }
|
| +}
|
|
|