2011-12-16 11:27:52 -08:00
|
|
|
#filter substitution
|
|
|
|
package @ANDROID_PACKAGE_NAME@.tests;
|
|
|
|
|
|
|
|
import @ANDROID_PACKAGE_NAME@.*;
|
2012-01-05 18:36:17 -08:00
|
|
|
import android.app.Activity;
|
2011-12-16 11:27:52 -08:00
|
|
|
|
2012-01-05 07:20:22 -08:00
|
|
|
public class testNewTab extends BaseTest {
|
2012-05-25 17:26:04 -07:00
|
|
|
@Override
|
|
|
|
protected int getTestType() {
|
|
|
|
return TEST_MOCHITEST;
|
|
|
|
}
|
|
|
|
|
2012-01-05 07:20:22 -08:00
|
|
|
public void testNewTab() {
|
2012-02-02 07:09:26 -08:00
|
|
|
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
|
|
|
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
|
2012-05-22 16:25:30 -07:00
|
|
|
String tabCountText = null;
|
|
|
|
String urlbarText = null;
|
|
|
|
Activity activity = null;
|
|
|
|
Element urlbar = null;
|
2012-01-24 06:46:36 -08:00
|
|
|
|
2012-01-05 18:36:17 -08:00
|
|
|
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
|
2012-01-05 07:20:22 -08:00
|
|
|
|
2012-01-24 06:46:36 -08:00
|
|
|
// Add one tab
|
|
|
|
Element tabs = mDriver.findElement(getActivity(), "tabs");
|
2012-05-22 16:25:30 -07:00
|
|
|
if (tabs != null) {
|
|
|
|
activity = getActivityFromClick(tabs);
|
|
|
|
urlbar = mDriver.findElement(activity, "awesomebar_text");
|
|
|
|
mActions.sendKeys(url);
|
|
|
|
if (urlbar != null) {
|
|
|
|
urlbarText = urlbar.getText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mAsserter.is(urlbarText, url, "Awesomebar url is fine");
|
2012-01-05 18:36:17 -08:00
|
|
|
hitEnterAndWait();
|
2012-01-05 07:20:22 -08:00
|
|
|
|
|
|
|
// See tab count
|
2012-01-05 18:36:17 -08:00
|
|
|
Element tabCount = mDriver.findElement(getActivity(), "tabs_count");
|
2012-05-22 16:25:30 -07:00
|
|
|
if (tabCount != null) {
|
|
|
|
tabCountText = tabCount.getText();
|
|
|
|
}
|
|
|
|
mAsserter.is(tabCountText, "2", "Number of tabs has increased");
|
2012-01-05 07:20:22 -08:00
|
|
|
|
|
|
|
// Click tab list
|
2012-01-24 06:46:36 -08:00
|
|
|
activity = getActivityFromClick(tabs);
|
|
|
|
Element addTab = mDriver.findElement(activity, "add_tab");
|
2012-05-22 16:25:30 -07:00
|
|
|
|
2012-01-24 06:46:36 -08:00
|
|
|
// Add another tab. The new tab has its own awesome bar activity, so it
|
|
|
|
// is important to use the new activity to fetch the awesome bar text.
|
2012-05-22 16:25:30 -07:00
|
|
|
urlbarText = null;
|
|
|
|
if (addTab != null) {
|
|
|
|
activity = getActivityFromClick(addTab);
|
|
|
|
mActions.sendKeys(url2);
|
|
|
|
urlbar = mDriver.findElement(activity, "awesomebar_text");
|
|
|
|
if (urlbar != null) {
|
|
|
|
urlbarText = urlbar.getText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mAsserter.is(urlbarText, url2, "URL is still fine");
|
2012-01-05 07:20:22 -08:00
|
|
|
|
2012-01-05 18:36:17 -08:00
|
|
|
hitEnterAndWait();
|
2012-01-24 06:46:36 -08:00
|
|
|
// Check tab count another time.
|
2012-05-22 16:25:30 -07:00
|
|
|
tabCountText = null;
|
|
|
|
if (tabCount != null) {
|
|
|
|
tabCountText = tabCount.getText();
|
|
|
|
}
|
|
|
|
mAsserter.is(tabCountText, "3", "Number of tabs has increased");
|
2012-01-05 07:20:22 -08:00
|
|
|
}
|
2011-12-16 11:27:52 -08:00
|
|
|
}
|