| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
| 8 import android.content.DialogInterface; | 8 import android.content.DialogInterface; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 | 10 |
| 11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
| 14 import org.chromium.chrome.shell.ChromeShellActivity; | 14 import org.chromium.chrome.shell.ChromeShellActivity; |
| 15 import org.chromium.chrome.shell.ChromeShellApplication; | |
| 16 import org.chromium.chrome.shell.ChromeShellTestBase; | 15 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * Tests org.chromium.chrome.browser.webapps.AddToHomescreenDialog by verifying | 18 * Tests org.chromium.chrome.browser.webapps.AddToHomescreenDialog by verifying |
| 20 * that the calling the show() method actually shows the dialog and checks that | 19 * that the calling the show() method actually shows the dialog and checks that |
| 21 * some expected elements inside the dialog are present. | 20 * some expected elements inside the dialog are present. |
| 22 * | 21 * |
| 23 * This is mostly intended as a smoke test because the dialog isn't used in | 22 * This is mostly intended as a smoke test because the dialog isn't used in |
| 24 * Chromium for the moment. | 23 * Chromium for the moment. |
| 25 */ | 24 */ |
| 26 public class AddToHomescreenDialogTest extends ChromeShellTestBase { | 25 public class AddToHomescreenDialogTest extends ChromeShellTestBase { |
| 27 private ChromeShellActivity mActivity; | 26 private ChromeShellActivity mActivity; |
| 28 | 27 |
| 29 @Override | 28 @Override |
| 30 public void setUp() throws Exception { | 29 public void setUp() throws Exception { |
| 31 super.setUp(); | 30 super.setUp(); |
| 32 mActivity = launchChromeShellWithBlankPage(); | 31 mActivity = launchChromeShellWithBlankPage(); |
| 33 ChromeShellApplication application = | |
| 34 (ChromeShellApplication) mActivity.getApplication(); | |
| 35 } | 32 } |
| 36 | 33 |
| 37 @SmallTest | 34 @SmallTest |
| 38 @Feature("{Webapp}") | 35 @Feature("{Webapp}") |
| 39 public void testSmoke() throws InterruptedException { | 36 public void testSmoke() throws InterruptedException { |
| 40 assertTrue(waitForActiveShellToBeDoneLoading()); | 37 assertTrue(waitForActiveShellToBeDoneLoading()); |
| 41 | 38 |
| 42 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 39 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 43 @Override | 40 @Override |
| 44 public void run() { | 41 public void run() { |
| 45 assertNull(AddToHomescreenDialog.getCurrentDialogForTest()); | 42 assertNull(AddToHomescreenDialog.getCurrentDialogForTest()); |
| 46 | 43 |
| 47 AddToHomescreenDialog.show(mActivity, mActivity.getActiveTab()); | 44 AddToHomescreenDialog.show(mActivity, mActivity.getActiveTab()); |
| 48 AlertDialog dialog = AddToHomescreenDialog.getCurrentDialogForTe
st(); | 45 AlertDialog dialog = AddToHomescreenDialog.getCurrentDialogForTe
st(); |
| 49 assertNotNull(dialog); | 46 assertNotNull(dialog); |
| 50 | 47 |
| 51 assertTrue(dialog.isShowing()); | 48 assertTrue(dialog.isShowing()); |
| 52 | 49 |
| 53 assertNotNull(dialog.findViewById(R.id.title)); | 50 assertNotNull(dialog.findViewById(R.id.title)); |
| 54 assertNotNull(dialog.findViewById(R.id.text)); | 51 assertNotNull(dialog.findViewById(R.id.text)); |
| 55 assertNotNull(dialog.getButton(DialogInterface.BUTTON_POSITIVE))
; | 52 assertNotNull(dialog.getButton(DialogInterface.BUTTON_POSITIVE))
; |
| 56 assertNotNull(dialog.getButton(DialogInterface.BUTTON_NEGATIVE))
; | 53 assertNotNull(dialog.getButton(DialogInterface.BUTTON_NEGATIVE))
; |
| 57 } | 54 } |
| 58 }); | 55 }); |
| 59 } | 56 } |
| 60 } | 57 } |
| OLD | NEW |