| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.app.Dialog; | 7 import android.app.Dialog; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.LargeTest; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.widget.Button; | 10 import android.widget.Button; |
| 11 import android.widget.ListView; | 11 import android.widget.ListView; |
| 12 | 12 |
| 13 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
| 14 import org.chromium.base.test.util.RetryOnFailure; | 14 import org.chromium.base.test.util.RetryOnFailure; |
| 15 import org.chromium.chrome.R; | 15 import org.chromium.chrome.R; |
| 16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 17 import org.chromium.components.security_state.ConnectionSecurityLevel; | 17 import org.chromium.components.security_state.ConnectionSecurityLevel; |
| 18 import org.chromium.content.browser.test.util.Criteria; | 18 import org.chromium.content.browser.test.util.Criteria; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 /** | 120 /** |
| 121 * The messages include <link> ... </link> or <link1> ... </link1>, <link2>
... </link2> | 121 * The messages include <link> ... </link> or <link1> ... </link1>, <link2>
... </link2> |
| 122 * sections that are used to create clickable spans. For testing the message
s, this function | 122 * sections that are used to create clickable spans. For testing the message
s, this function |
| 123 * returns the raw string without the tags. | 123 * returns the raw string without the tags. |
| 124 */ | 124 */ |
| 125 private static String removeLinkTags(String message) { | 125 private static String removeLinkTags(String message) { |
| 126 return message.replaceAll("</?link1>", "").replaceAll( | 126 return message.replaceAll("</?link1>", "").replaceAll( |
| 127 "</?link2>", "").replaceAll("</?link>", ""); | 127 "</?link2>", "").replaceAll("</?link>", ""); |
| 128 } | 128 } |
| 129 | 129 |
| 130 @SmallTest | 130 @LargeTest |
| 131 public void testCancel() throws InterruptedException { | 131 public void testCancel() throws InterruptedException { |
| 132 Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting(); | 132 Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting(); |
| 133 assertTrue(dialog.isShowing()); | 133 assertTrue(dialog.isShowing()); |
| 134 | 134 |
| 135 final ListView items = (ListView) dialog.findViewById(R.id.items); | 135 final ListView items = (ListView) dialog.findViewById(R.id.items); |
| 136 final Button button = (Button) dialog.findViewById(R.id.positive); | 136 final Button button = (Button) dialog.findViewById(R.id.positive); |
| 137 | 137 |
| 138 // The 'Connect' button should be disabled and the list view should be h
idden. | 138 // The 'Connect' button should be disabled and the list view should be h
idden. |
| 139 assertFalse(button.isEnabled()); | 139 assertFalse(button.isEnabled()); |
| 140 assertEquals(View.GONE, items.getVisibility()); | 140 assertEquals(View.GONE, items.getVisibility()); |
| 141 | 141 |
| 142 dialog.dismiss(); | 142 dialog.dismiss(); |
| 143 | 143 |
| 144 CriteriaHelper.pollUiThread(new Criteria() { | 144 CriteriaHelper.pollUiThread(new Criteria() { |
| 145 @Override | 145 @Override |
| 146 public boolean isSatisfied() { | 146 public boolean isSatisfied() { |
| 147 return mChooserDialog.mSelectedDeviceId.equals(""); | 147 return mChooserDialog.mSelectedDeviceId.equals(""); |
| 148 } | 148 } |
| 149 }); | 149 }); |
| 150 } | 150 } |
| 151 | 151 |
| 152 @SmallTest | 152 @LargeTest |
| 153 public void testSelectItem() throws InterruptedException { | 153 public void testSelectItem() throws InterruptedException { |
| 154 Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting(); | 154 Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting(); |
| 155 | 155 |
| 156 TextViewWithClickableSpans statusView = | 156 TextViewWithClickableSpans statusView = |
| 157 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); | 157 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); |
| 158 final ListView items = (ListView) dialog.findViewById(R.id.items); | 158 final ListView items = (ListView) dialog.findViewById(R.id.items); |
| 159 final Button button = (Button) dialog.findViewById(R.id.positive); | 159 final Button button = (Button) dialog.findViewById(R.id.positive); |
| 160 final int position = 1; | 160 final int position = 1; |
| 161 | 161 |
| 162 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 162 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 178 R.string.usb_chooser_dialog_footnote_text)), | 178 R.string.usb_chooser_dialog_footnote_text)), |
| 179 statusView.getText().toString()); | 179 statusView.getText().toString()); |
| 180 assertFalse(button.isEnabled()); | 180 assertFalse(button.isEnabled()); |
| 181 assertEquals(View.VISIBLE, items.getVisibility()); | 181 assertEquals(View.VISIBLE, items.getVisibility()); |
| 182 | 182 |
| 183 selectItem(mChooserDialog, position); | 183 selectItem(mChooserDialog, position); |
| 184 | 184 |
| 185 assertEquals("device_id_1", mChooserDialog.mSelectedDeviceId); | 185 assertEquals("device_id_1", mChooserDialog.mSelectedDeviceId); |
| 186 } | 186 } |
| 187 } | 187 } |
| OLD | NEW |