O'Reilly logo

Android Application Testing Guide by Diego Torres Milano

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding functionality

The user interface is in place. Now we start adding some basic functionality.

This functionality will include the code to handle the actual temperature conversion.

Temperature conversion

From the list of requirements we can obtain this statement: When one temperature is entered in one field the other one is automatically updated with the conversion.

Following our plan we must implement this as a test to verify that the correct functionality is there. Our test would look something like this:

@UiThreadTest
public final void testFahrenheitToCelsiusConversion() {
mCelsius.clear();
mFahrenheit.clear();
final double f = 32.5;
mFahrenheit.requestFocus();
mFahrenheit.setNumber(f);
mCelsius.requestFocus(); final double expectedC = TemperatureConverter.fahrenheitToCelsius(f); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required