Keyboard Geometry Builder


Source link: https://github.com/evernote/kgb

Keyboard Geometry Builder and espresso action

What is it?

The Keyboard Geometry Builder (kgb) is a test tool to help reduce the incidences of regression stemming from difficulties in correctly handling the wide variety of Android keyboards, and how they interact (in particular) with WebViews.

Why is it needed?

Until now, automated testing has relied in injecting key events rather than actually stimulating the keyboard. This works better… but misses the majority of keyboard issues.

Architecture

The kgb is composed of three parts:

  • a client app, that can be run with minimal user input, and which uses heuristics to find the position of most keys on the keyboard, then uploads the key locations to a web service
  • a web service, currently running as a Google Apps script, backed by a spreadsheet, stores the results of client runs, and can serve the best match for a given configuration to the test module
  • the test module is integrated with the Espresso framework, and can be used to run the same or very similar tests that we currently run, but using keyboard stimulation rather than simulation

How to run the builder

The builder app and espresso module are hosted as their own project. You can check it out and build it with Gradle.

Requirements:

  • rooted device
  • network access

The first time you run it, if your device is rooted, you should see a prompt like the one below. Allow root for ever to the app. If the Superuser request doesn’t come directly, you can open the Superuser or SuperSU app to help push it along…

The app then tries to find all the keys for the currently-configured keyboard (you should see a blue crawler where it tries to hit keys, and red dots where it finds them), and if it’s successful, it uploads the data.

If you have multiple keyboards installed on the device, the builder will iterate through them and upload all keyboard maps.

You can stop the app by tapping the X in the upper-right (not pictured).

Usage

Add the following dependency to your Gradle config:

dependencies {

  testCompile 'com.evernote:kgb:0.2.0' 
}

How to develop tests for it

Sample tests are in class app/src/androidTest/java/com/evernote/keyboardgeometrybuilder/ApplicationTest.java

How to run tests

Requirements:

  • Android 4.3 or rooted device (with Android 4.3, UiAutomator is used to inject taps on the keyboard and switching keyboards)
  • network access

With Android 4.2 and earlier, the first time tests are run on a given device, root access must be granted to the application.

How can I keep my keyboard maps separate from the shared data?

There is value in having a single shared repository for keyboard maps, but if you want to use a separate one:

  • create a new Google Spreadsheet
  • create a new macro, and paste the content of kgb.gs into it
  • edit the macro to point to the spreadsheet
  • publish the macro
  • edit com.evernote.espressokeyboard.KeyLocations.MACRO_ID to point to the macro

Limitations

  • the builder can only run on a rooted device, and once the root privileges have been granted keyboards have a lot of leeway, so tests may require more maintenance, as keyboards evolve and keys move don’t expect exact results, in particular with casing: at the start of a line, the keyboard will want to use an uppercase letter, whereas using injected events type what you tell them to
  • in particular, be aware that capitalizing the scheme of a URL (http) turns it into not-a-link…
  • because the builder is based on automated heuristics, it may have trouble if the keyboard layout is too strange (split keyboards, keyboards requiring swipes, etc.)
  • the system tries to account for different screen sizes and variations in density, fonts, navbar, etc, but it’s safer to run the builder on the same devices that will be running the tests (the requirements are the same)

Demo

Disclaimer: there’s a long pause at the beginning… but then it goes on to test CE and NE with two different keyboards…

License

Copyright (c) 2007-2015 by Evernote Corporation, All rights reserved.  Use of the source code and binary libraries included in this package is permitted under the following terms:  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 

Other licenses

Two files in this repo are licensed differently than the rest:

Resources

Android library to display month, list calendar within the app. Can be use as date picker or fully ready calendar.

IncDec library will allow you to perform increment and decrement operation. As it supports single click and long press, it enhances UX solving the delay problem in the typical number picker.

Download manager via okhttp.

This is amazing android library to add tab-digits with an old -fashion transition as old clock does.

Cinder helps you write concise and declarative code with Android’s data binding Observable classes.

Perm is a library that makes it simple to check and request Android Permissions at runtime (like Camera or GPS) for Apps targeting Android 6 or more.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes