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

it.tidalwave.bluebill.mobile.android.impl.TestHelperTouch 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.impl;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.ImageButton;
import android.widget.ListView;
import com.jayway.android.robotium.solo.Solo;
import it.tidalwave.bluebill.mobile.android.TestHelper;
import it.tidalwave.util.logging.Logger;
import java.util.List;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 **********************************************************************************************************************/
public class TestHelperTouch extends TestHelper
  {
    private static final String CLASS = TestHelperTouch.class.getName();
    private static final Logger logger = Logger.getLogger(CLASS);

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    public TestHelperTouch (final @Nonnull ActivityInstrumentationTestCase2 instrumentationTestCase,
                            final @Nonnull Solo solo)
      {
        super(instrumentationTestCase, solo);
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Override
    public void clickOnImageButtonById (final int id)
      {
        final List buttons = solo.getCurrentImageButtons();

        for (int i = 0; i < buttons.size(); i++)
          {
            final ImageButton button = buttons.get(i);

            if (button.getId() == id)
              {
                logger.info(">>>> Clicking on ImageButton #%d  ...", i);
                clickViewWithTouchUtils(button);
//                    solo.clickOnImageButton(i);
                return;
              }
          }

        throw new AssertionError("Cannot find button #" + id + " on " + solo.getCurrentActivity() + ": " + buttons);
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Override
    public void clickOnListView (final @Nonnull ListView listView, final @Nonnegative int index)
      {
        clickViewWithTouchUtils(listView.getChildAt(index));
//            solo.clickInList(listIndex, index);
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Override
    public void clickOnListView (final @Nonnull ListView listView, final @Nonnull String text)
      {
        throw new AssertionError("Not implemented yet");
        //        clickViewWithTouchUtils(listView.getChildAt(index));
//            solo.clickInList(listIndex, index);
      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    @Override
    public void confirmDialog()
      {
        solo.clickOnButton("Ok");
      }
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy