it.tidalwave.bluebill.mobile.android.taxonomy.browser.TaxonPicker Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - open source birdwatching
* ==========================================
*
* Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
* http://bluebill.tidalwave.it/mobile/
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* $Id: TaxonPicker.java,v bb7f9a15a7da 2010/08/07 21:27:21 fabrizio $
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.android.taxonomy.browser;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: $
*
**********************************************************************************************************************/
public abstract class TaxonPicker
{
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected static class SimpleTaxonPicker extends TaxonPicker
{
@Nonnegative
private final int pickIndex;
public SimpleTaxonPicker (final @Nonnegative int pickIndex)
{
this.pickIndex = pickIndex;
}
public void pickTaxon (final @Nonnull TaxonomyBrowserActivityTestHelper taxonomyBrowserActivity)
{
taxonomyBrowserActivity.clickOnKeyboardButton(); // FIXME: doesn't work
taxonomyBrowserActivity.assertTaxaCount(954);
taxonomyBrowserActivity.clickOnTaxon(pickIndex);
}
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected static class FilterTaxonPicker extends TaxonPicker
{
@Nonnull
private final String filterKeys;
@Nonnegative
private final int finalTaxaCount;
@Nonnull
private final String finalHeaderMessage;
@Nonnegative
private final int pickIndex;
public FilterTaxonPicker (final @Nonnull String filterKeys,
final @Nonnegative int finalTaxaCount,
final @Nonnull String finalHeaderMessage,
final @Nonnegative int pickIndex)
{
this.filterKeys = filterKeys;
this.finalTaxaCount = finalTaxaCount;
this.finalHeaderMessage = finalHeaderMessage;
this.pickIndex = pickIndex;
}
public void pickTaxon (final @Nonnull TaxonomyBrowserActivityTestHelper taxonomyBrowserActivity)
throws InterruptedException
{
taxonomyBrowserActivity.clickOnKeyboardButton(); // FIXME: doesn't work
taxonomyBrowserActivity.assertTaxaCount(954);
taxonomyBrowserActivity.assertHeaderText("954 species");
taxonomyBrowserActivity.filterKeys(filterKeys);
Thread.sleep(2000);
taxonomyBrowserActivity.assertTaxaCount(finalTaxaCount);
taxonomyBrowserActivity.assertHeaderText(finalHeaderMessage);
taxonomyBrowserActivity.clickOnTaxon(pickIndex);
}
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public abstract void pickTaxon (@Nonnull TaxonomyBrowserActivityTestHelper taxonomyBrowserActivity)
throws Exception;
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public static TaxonPicker pickTheLittleGrebe()
{
return new FilterTaxonPicker("lttlg", 5, "5 species", 2);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public static TaxonPicker pickTheEurasianSpoonBill()
{
return new FilterTaxonPicker("espnb", 2, "2 species", 1);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public static TaxonPicker pickTheTawnyOwl()
{
return new FilterTaxonPicker("twn", 4, "4 species", 1);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public static HistoricTaxaAsserter assertHistoricTaxaCount (final @Nonnegative int count)
{
return new SimpleHistoricTaxaAsserter(count);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy