Index: components/devtools_bridge/android/javatests/src/org/chromium/components/devtools_bridge/tests/DebugActivity.java |
diff --git a/components/devtools_bridge/android/javatests/src/org/chromium/components/devtools_bridge/tests/DebugActivity.java b/components/devtools_bridge/android/javatests/src/org/chromium/components/devtools_bridge/tests/DebugActivity.java |
index 1cadbf2f2e80bbc103b4322bed9eb77d14dce55f..13db1cde39d49a397ff48673fdbc35683de530b1 100644 |
--- a/components/devtools_bridge/android/javatests/src/org/chromium/components/devtools_bridge/tests/DebugActivity.java |
+++ b/components/devtools_bridge/android/javatests/src/org/chromium/components/devtools_bridge/tests/DebugActivity.java |
@@ -6,17 +6,26 @@ package org.chromium.components.devtools_bridge.tests; |
import android.app.Activity; |
import android.content.Intent; |
+import android.os.Build; |
import android.os.Bundle; |
+import android.view.LayoutInflater; |
import android.view.View; |
+import android.view.ViewGroup; |
import android.widget.Button; |
import android.widget.LinearLayout; |
import android.widget.LinearLayout.LayoutParams; |
import android.widget.TextView; |
+import org.chromium.components.devtools_bridge.apiary.ApiaryClientFactory; |
+import org.chromium.components.devtools_bridge.apiary.TestApiaryClientFactory; |
+import org.chromium.components.devtools_bridge.ui.GCDRegistrationFragment; |
+ |
/** |
* Activity for testing devtools bridge. |
*/ |
public class DebugActivity extends Activity { |
+ private static final int LAYOUT_ID = 1000; |
+ |
private LinearLayout mLayout; |
@Override |
@@ -24,15 +33,17 @@ public class DebugActivity extends Activity { |
super.onCreate(savedInstanceState); |
mLayout = new LinearLayout(this); |
+ mLayout.setId(LAYOUT_ID); |
mLayout.setOrientation(LinearLayout.VERTICAL); |
- String intro = "To test LocalTunnelBridge manually: \n" + |
- "1. Enable USB debugging.\n" + |
- "2. Run ChromeShell along with this app.\n" + |
- "3. Start the LocalTunnelBridge.\n" + |
- "4. Connect the device to a desktop via USB.\n" + |
- "5. Open chrome://inspect#devices on desktop Chrome.\n" + |
- "6. Observe 2 identical Chrome Shells on the device."; |
+ String intro = |
+ "To test LocalTunnelBridge manually: \n" |
+ + "1. Enable USB debugging.\n" |
+ + "2. Run ChromeShell along with this app.\n" |
+ + "3. Start the LocalTunnelBridge.\n" |
+ + "4. Connect the device to a desktop via USB.\n" |
+ + "5. Open chrome://inspect#devices on desktop Chrome.\n" |
+ + "6. Observe 2 identical Chrome Shells on the device."; |
TextView textView = new TextView(this); |
textView.setText(intro); |
@@ -45,6 +56,12 @@ public class DebugActivity extends Activity { |
LayoutParams layoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, |
LayoutParams.MATCH_PARENT); |
+ |
+ getFragmentManager() |
+ .beginTransaction() |
+ .add(LAYOUT_ID, new TestGCDRegistrationFragment()) |
+ .commit(); |
+ |
setContentView(mLayout, layoutParam); |
} |
@@ -69,5 +86,49 @@ public class DebugActivity extends Activity { |
startService(intent); |
} |
} |
+ |
+ private static class TestGCDRegistrationFragment |
+ extends GCDRegistrationFragment implements View.OnClickListener { |
+ private Button mButton; |
+ |
+ @Override |
+ public View onCreateView( |
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
+ mButton = new Button(getActivity()); |
+ mButton.setOnClickListener(this); |
+ updateText(); |
+ return mButton; |
+ } |
+ |
+ public void updateText() { |
+ mButton.setText(isRegistered() |
+ ? "Unregister (registered for " + getOwner() + ")" |
+ : "Register in GCD"); |
+ } |
+ |
+ @Override |
+ protected void onRegistrationStatusChange() { |
+ updateText(); |
+ } |
+ |
+ @Override |
+ protected ApiaryClientFactory newClientFactory() { |
+ return new TestApiaryClientFactory(); |
+ } |
+ |
+ @Override |
+ protected String generateDisplayName() { |
+ return Build.MODEL + " Test app"; |
+ } |
+ |
+ @Override |
+ public void onClick(View v) { |
+ if (!isRegistered()) { |
+ register(); |
+ } else { |
+ unregister(); |
+ } |
+ } |
+ } |
} |