All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.bluebill.mobile.android.taxonomy.browser.TaxonPicker Maven / Gradle / Ivy

The newest version!
/***********************************************************************************************************************
 *
 * blueBill Mobile - Android - open source birding
 * Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * 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.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluebill.tidalwave.it/mobile
 * SCM: https://java.net/hg/bluebill-mobile~android-src
 *
 **********************************************************************************************************************/
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
  {
    public static final Class TaxonPicker = TaxonPicker.class;
    
    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    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); // Smart with initial
//        return new FilterTaxonPicker("lttlg", 6, "6 species", 2); // Smart
        return new FilterTaxonPicker("grebe", 6, "6 species", 2);   // Exact substring
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Nonnull
    public static TaxonPicker pickTheEurasianSpoonBill()
      {
//        return new FilterTaxonPicker("espnb", 2, "2 species", 1); // Smart with initial
//        return new FilterTaxonPicker("spnb", 6, "6 species", 2);  // Smart
        return new FilterTaxonPicker("spoon", 3, "3 species", 1);   // Exact substring
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Nonnull
    public static TaxonPicker pickTheTawnyOwl()
      {
//        return new FilterTaxonPicker("twn", 4, "4 species", 1);   // Smart with initial
//        return new FilterTaxonPicker("twnw", 5, "5 species", 1);  // Smart
        return new FilterTaxonPicker("owl", 21, "21 species", 18);  // Exact substring
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Nonnull
    public static HistoricTaxaAsserter assertHistoricTaxaCount (final @Nonnegative int count)
      {
        return new SimpleHistoricTaxaAsserter(count);
      }
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy