Showing posts with label wear. Show all posts
Showing posts with label wear. Show all posts

Sunday, July 12, 2015

How to test a watch face?

Fit Cat is an Android Wear watch face that shows the time with a different cat depending on how many steps you walked that day. How do you test something like that? Walk a lot while looking at your watch all the time?

I wrote Fit Cat with a modular structure that allows both unit testing and instrumentation testing.

All Android Wear apps have two modules, mobile and wear. I made them both depend on a ui module, which has the implementation for rendering the bitmap for the watch face. This in turn depends on a lib module, which is a pure Java library.

Unit testing

The lib module contains the pure Java class ActionStore, which has the logic to determine which image to show depending on the time, steps and randomizer value:

  • The number of steps decides the action level, each mapping to multiple actions.
  • Within that level, an action is picked randomly.
  • Within that action, the time determines the image for the animation frame.

The watch face calls actionStore.getImage(time, steps, randomizerValue) to get the image file name. In the junit tests, various values of time, steps and randomizerValue are passed to that function, and the resulting image file names are verified.

Instrumentation testing

Besides verifying the logic, I also want to visually inspect the rendered bitmaps. The ui module has a Renderer class with a function drawWatchFace(canvas, steps, action, time, batteryPercent). I test this function by adding an InstrumentationTestCase to the mobile module, which enumerates all possible actions and write the animation frames to sdcard. I then combine them into animated gifs for visual inspection.

Since the wear module also uses this Renderer class from the ui module, I am confident that the layout for all the different animation frames are good. Plus, I get to see all the cute actions Fit Cat does!

Monday, June 1, 2015

Fit Cat at Google I/O

One of the most exciting things at Google I/O this year for me was to meet Virginia Poltrack in person.

Online introduction

I wanted to make an Android Wear watch face with a cat that does different things depending on how many steps you took that day. The first order of business is to find an illustrator to draw the cute cats. I posted on Google Plus to ask for recommendations, and my friend Macy introduced me to Virginia. At that point I didn't say anything about a watch face, so I was really surprised when I saw this on Virginia's profile:

Yup, not only that she is an amazing illustrator, she has made watch faces before!

Rapid iterations

Once I explained my idea to Virginia, we both got really excited and started working right away.

Our goal was to launch before I/O, and we did it! Twice, in fact: first with just the cat, and then with pedometer integration.

Women Techmakers interview

At this point we have only worked together online, so we were really looking forward to seeing each other at I/O. Then Natalie Villalobos from Women Techmakers gave us a wonderful surprise: she interviewed both of us about Fit Cat!

Fit Cat everywhere!

Google I/O was a perfect place to test Fit Cat since I tend to walk a lot during conferences. I snapped photos of it throughout the day.

My friends started doing the same, and it was so heartwarming to see Fit Cat everywhere!

Only the beginning

It has been such a pleasure working with Virginia. We are already plotting our next projects together, so stay tuned!