Accessibility. Adding features to support users with impaired vision, mobility, or hearing

Similar documents
Testing on Android. Mobile Application Development. Jakob Mass MTAT Fall MTAT

Unit Testing. CS 240 Advanced Programming Concepts

android-espresso #androidespresso

Project Design and Implementation Report VEHICULAR TRAFFIC ANALYTICS

Checking Current Code Coverage

What is the Selendroid?

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Chapter 1. Installation and Setup

Testing Your Android Applications

Unit Testing & Testability

White-box testing. Software Reliability and Testing - Barbara Russo SERG - Laboratory of Empirical Software Engineering.

Software Engineering a.a Unit Tests for SpringMVC Prof. Luca Mainetti University of Salento

XML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.

Android Best Practices

Junit Overview. By Ana I. Duncan

Hello World. Lesson 1. Create your first Android. Android Developer Fundamentals. Android Developer Fundamentals

Topics covered. Introduction to JUnit JUnit: Hands-on session Introduction to Mockito Mockito: Hands-on session. JUnit & Mockito 2

Software Engineering Large Practical: Preferences, storage, and testing

Google Maps Troubleshooting

Chapter 2 Welcome App

Unit Tes2ng Ac2vity. SWEN-261 Introduc2on to So3ware Engineering. Department of So3ware Engineering Rochester Ins2tute of Technology

Installing. Download the O365 suite including OneDrive for Business: 1. Open the Google Play Store on your Android device

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Unit testing basics & more...

SWE 434 Software Testing and Validation

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

South Africa

Test-Driven Development JUnit

Android Studio is google's official IDE(Integrated Development Environment) for Android Developers.

Android. Lesson 1. Introduction. Android Developer Fundamentals. Android Developer Fundamentals. to Android 1

Testing with JUnit 1

Embracing. with. Noopur Gupta. Eclipse JDT co-lead. IBM

Appium mobile test automation

Test automation / JUnit. Building automatically repeatable test suites

Test automation Test automation / JUnit

Java Training Center - Android Application Development

Basic Keywords Practice Session

In order to update you will have to uninstall the current version and install the newer version using the same procedure.

Android Developer Nanodegree Syllabus

Test-Driven Development JUnit

Unit Testing Activity

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Lab Android Development Environment

Manual Android Virtual Device Failed To Load Click Details

Course Syllabus. Course Title. Who should attend? Course Description. Android ( Level 1 )

Android Essentials with Java

Unit Testing and JUnit

Android App Development

HCA Tech Note 120. Configuring the Control UI Home Page. Option 1: HCA constructs the home page

Introduction to Software Engineering: Tools and Environments. Session 5. Oded Lachish

Unit Testing. SWEN-610 Foundations of Software Engineering. Department of Software Engineering Rochester Institute of Technology

SD Module-1 Android Dvelopment

Mobile Application Development

TalkToMe: A beginner App Inventor app

Lab - Working with Android

JUnit Programming Cookbook. JUnit Programming Cookbook

Tutorial on OpenCV for Android Setup

Pemrograman Mobile. Lesson 1. Introduction to Android. Create Your First Android App. Nizar Rabbi Radliya

Zello Quick Start Guide for Kyocera TORQUE

Enabling Mobile Automation Testing using Open Source Tools

LarvaLight User Manual

Testing Mobile Apps CS 4720 Mobile Application Development

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Copyright

ATC Android Application Development

ANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012

Developing Android applications in Windows

(Refer Slide Time: 1:07)

Nextiva Drive The Setup Process Mobility & Storage Option

05. RecyclerView and Styles

Android Application Development using Kotlin

Step 1 Turn on the device and log in with the password, PIN, or other passcode, if necessary.

Unit Testing. SWEN-261 Introduction to Software Engineering. Department of Software Engineering Rochester Institute of Technology

Table of contents. 2 Samsung Care. 3 Know Your Device. 5 S Pen. 7 Device Setup. 12 Home Screen. 18 Apps. 19 Calls. 20 Voic .

Programmieren II. Unit Testing & Test-Driven Development. Alexander Fraser.

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Comprehensive AngularJS Programming (5 Days)

ScanKey. User s Manual Version: Page 1 of 19

Testing on Steriods EECS /30

Lab 6: Google Maps Android API v2 Android Studio 10/14/2016

INTRODUCTION TO JAVA PROGRAMMING JAVA FUNDAMENTALS PART 2

Guide to fix the problem with Problets

Axon Capture for Android Devices User Manual

Software Engineering I (02161)

Testing. Topics. Types of Testing. Types of Testing

Syllabus- Java + Android. Java Fundamentals

Pieter van den Hombergh Stefan Sobek. April 18, 2018

Lab #1: A Quick Introduction to the Eclipse IDE

IGEEKS TECHNOLOGIES. Software Training Division. Academic Live Projects For BE,ME,MCA,BCA and PHD Students

Mock Objects and the Mockito Testing Framework Carl Veazey CSCI Friday, March 23, 12

BSCS 514- Computer Graphics. Course Supervisor : Dr. Humera Tariq Hands on Lab Sessions: Mr. Faraz Naqvi

Tutorial on OpenCV for Android Setup

Firebase Essentials. Android Edition

Xamarin for C# Developers

Installation Instructions

Required Core Java for Android application development

Axon Capture for Android Devices User Manual

Software Development Tools. COMP220/COMP285 Sebastian Coope Eclipse and JUnit: Creating and running a JUnit test case

Accession Communicator for Mobile

Annotations in Java (JUnit)

Transcription:

Accessibility Adding features to support users with impaired vision, mobility, or hearing

TalkBack TalkBack is an Android screen reader made by Google. It speaks out the contents of a screen based on what the user is doing. The emulator does not support TalkBack, so you have to have an Android device to deploy onto. To enable TalkBack, launch Settings and press Accessibility. Press on TalkBack under the Services heading. Then press the switch near the top right of the screen to turn TalkBack on.

A dialog asking for permission to access certain information, e.g. observing the user s actions, altering certain settings, such as turning on Explore by Touch. Green outlines highlight UI elements that have accessibility focus. Explore by Touch speaks information about an item immediately after it is pressed, assuming that the item specifies information TalkBack can read. Swiping moves the focus

Making Non-Text Elements Readable Normally, non-text items will result in TalkBack announcing Button unlabelled. Double-tap to activate. This can be changed by, e.g. adding a content description to an ImageButton. Add content description strings (res/values/strings.xml): <resources>... <string name="crime_details_label">details</string> <string name="crime_solved_label">solved</string> <string name="crime_photo_button_description">take photo of crime scene</string> <string name="crime_photo_no_image_description"> Crime scene photo (not set) </string> <string name="crime_photo_image_description">crime scene photo (set)</string>... </resources>

Descriptions for ImageView and ImageButton: <ImageView android:id="@+id/crime_photo" android:layout_width="80dp" android:layout_height="80dp" android:background="@android:color/darker_gray" android:croptopadding="true" android:scaletype="centerinside" android:contentdescription="@string/crime_photo_no_image_description" /> <ImageButton android:id="@+id/crime_camera" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_camera" android:contentdescription="@string/crime_photo_button_description" />

Dynamic Content Descriptions public class CrimeFragment extends Fragment {... private void updatephotoview() { if (mphotofile == null!mphotofile.exists()) { mphotoview.setimagedrawable(null); mphotoview.setcontentdescription( getstring(r.string.crime_photo_no_image_description)); else {... mphotoview.setimagebitmap(bitmap); mphotoview.setcontentdescription( getstring(r.string.crime_photo_image_description));

Unit Testing JUnit

Two Types of Unit Tests Local unit tests Located at module-name/src/test/java/. These tests run on the local JVM and do not have access to functional Android framework APIs. Instrumented tests Located at module-name/src/androidtest/java/. These are all tests that must run on an Android hardware device or an Android emulator. Instrumented tests are built into an APK that runs on the device alongside your app under test. The system runs your test APK and your app under tests in the same process, so your tests can invoke methods and modify fields in the app, and automate user interaction with your app.

Local vs Instrumental

Testing

JUnit Write a unit or integration test class as a JUnit 4 test class. The framework offers a convenient way to perform common setup, teardown, and assertion operations in your test. A basic JUnit 4 test class is a Java class that contains one or more test methods. Test methods begins with the @Test annotation and contains the code to exercise and verify a single functionality, i.e., a logical unit in the component to be tested. The following snippet shows an example JUnit 4 integration test that uses the Espresso APIs to perform a click action on a UI element, then checks to see if an expected string is displayed.

Integration Test @RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityInstrumentationTest { @Rule public ActivityTestRule mactivityrule = new ActivityTestRule<>( MainActivity.class); @Test public void sayhello(){ onview(withtext("say hello!")).perform(click()); onview(withid(r.id.textview)).check(matches(withtext("hello, World!")));

JUnit Annotations @Before: Use this annotation to specify a block of code that contains test setup operations. The test class invokes this code block before each test. You can have multiple @Before methods but the order in which the test class calls these methods is not guaranteed. @After: This annotation specifies a block of code that contains test tear-down operations. The test class calls this code block after every test method. You can define multiple @After operations in your test code. Use this annotation to release any resources from memory.

JUnit Annotations @Test: Use this annotation to mark a test method. A single test class can contain multiple test methods, each prefixed with this annotation. @Rule: Rules allow you to flexibly add or redefine the behaviour of each test method in a reusable way. In Android testing, use this annotation together with one of the test rule classes that the Android Testing Support Library provides, such as ActivityTestRule or ServiceTestRule.

JUnit Annotations @BeforeClass: Use this annotation to specify static methods for each test class to invoke only once. This testing step is useful for expensive operations such as connecting to a database. @AfterClass: Use this annotation to specify static methods for the test class to invoke only after all tests in the class have run. This testing step is useful for releasing any resources allocated in the @BeforeClass block. @Test(timeout=): Some annotations support the ability to pass in elements for which you can set values. For example, you can specify a timeout period for the test. If the test starts but does not complete within the given timeout period, it automatically fails. You must specify the

Local Testing In the app's top-level build.gradle file, we need to specify these libraries as dependencies: dependencies { // Required -- JUnit 4 framework testcompile 'junit:junit:4.12' // Optional -- Mockito framework testcompile 'org.mockito:mockito-core:1.10.19' As a basic JUnit 4 test class, create a Java class that contains one or more test methods. A test method begins with the @Test annotation and contains the code to exercise and verify a single functionality in the component that you want to test.

Example The test method emailvalidator_correctemailsimple_returnstr ue verifies that the isvalidemail() method in the app under test returns the correct result. import org.junit.test; import java.util.regex.pattern; import static org.junit.assert.assertfalse; import static org.junit.assert.asserttrue; public class EmailValidatorTest { @Test public void emailvalidator_correctemailsimple_returnstrue() { assertthat(emailvalidator.isvalidemail("name@email.com"), is(true));...

Testing and Gradle The Android Plug-in for Gradle executes local unit tests against a modified version of the android.jar library, which does not contain any actual code. Method calls to Android classes from the unit test throw an exception. This is to make sure you test only your code and don t depend on any particular behaviour of the Android platform This can be changed by mocking.

Mocking an object To add a mock object to a local unit test: 1. Include the Mockito library dependency in build.gradle 2. At the beginning of the unit test class definition, add @RunWith(MockitoJUnitRunner.class) annotation. This annotation tells the Mockito test runner to validate that the usage of the framework is correct and simplifies the initialisation of mock objects. 3. To create a mock object for an Android dependency, add the @Mock annotation before the field declaration. 4. To stub the behaviour of the dependency, specify a condition and return value when the condition is met by using the when() and thenreturn() methods. With Mockito, you can configure mock objects to return some specific value when invoked.

Importing Mockito Select the Dependencies tab at the top of the screen, click the + button; Select the org.mockito:mockito-core dependency and click OK; Repeat for Hamcrest, searching for hamcrest-junit and selecting org.hamcrest:hamcrest-junit

Example: a mock Context object import static org.hamcrest.matcherassert.assertthat; import static org.hamcrest.corematchers.*; import static org.mockito.mockito.*; import org.junit.test; import org.junit.runner.runwith; import org.mockito.mock; import org.mockito.runners.mockitojunitrunner; import android.content.sharedpreferences; @RunWith(MockitoJUnitRunner.class) public class UnitTestSample { private static final String FAKE_STRING = "HELLO WORLD"; @Mock Context mmockcontext; @Test public void readstringfromcontext_localizedstring() { // Given a mocked Context injected into the object under test... when(mmockcontext.getstring(r.string.hello_word)).thenreturn(fake_string); ClassUnderTest myobjectundertest = new ClassUnderTest(mMockContext); //...when the string is returned from the object under test... String result = myobjectundertest.gethelloworldstring(); //...then the result should be the expected one. assertthat(result, is(fake_string));

Creating a test class To write unit tests we use a testing framework. The framework makes it easier to write and run a suite of tests together and see their output in Android Studio. JUnit is used as a testing framework on Android and has convenient integrations into Android Studio. Create a JUnit tests class. In SoundViewModel.java type Ctrl+Shift+T to make Android Studio navigate to a test class associated with the current class. If there is no test class, we are given the option to create a new one. Unit tests go in folder test

Setting up the test

Writing tests A test class A mock BeatBox class public class SoundViewModelTest { private BeatBox mbeatbox; private Sound msound; private SoundViewModel msubject; @Before public void setup() throws Exception { mbeatbox = mock(beatbox.class); msound = new Sound("assetPath"); msubject = new SoundViewModel(mBeatBox); msubject.setsound(msound); @Before Test subject Testing the title property public void setup() throws Exception { mbeatbox = mock(beatbox.class); msound = new Sound("assetPath"); msubject = new SoundViewModel(mBeatBox); msubject.setsound(msound); @Test public void exposessoundnameastitle() { assertthat(msubject.gettitle(), is(msound.getname()));