Transcript
Page 1: Coexisting of Android & Robots

www.immobilienscout24.de

www.immobilienscout24.de

Android Meetup Berlin | 30.05.2012 | Hasan Hosgel

Coexisting of Android and Robots Introduction to RoboGuice & Robotium

Page 2: Coexisting of Android & Robots

www.immobilienscout24.de

About me

Hasan Hoşgel Twitter: @alosdev Github: alosdev G+: Hasan Hosgel

Senior Developer

Mobile enthusiast, Man of action

Page 3: Coexisting of Android & Robots

| Coexisting of Android and Robots | Hasan Hosgel

Seite 3

ImmobilienScout24 Germany‘s leading real-estate portal

550 employees, 160 in the IT

Page 4: Coexisting of Android & Robots

| Coexisting of Android and Robots | Hasan Hosgel

Seite 4

ImmobilienScout24 Germany‘s leading real-estate portal

550 employees, 160 in the IT > 7.5 Million unique users

> 2 Billion PI > 260 Million Expose views ~ 1.5 Million active listings > 110,000 Vendors ... per month > 3 Mio App-Downloads

Page 5: Coexisting of Android & Robots

| Coexisting of Android and Robots | Hasan Hosgel

Seite 5

ImmobilienScout24 Germany‘s leading real-estate portal

550 employees, 160 in the IT

2 datacenter ~100 physical ~800 virtual ... machines

> 7.5 Million unique users > 2 Billion PI > 260 Million Expose views ~ 1.5 Million active listings > 110,000 Vendors ... per month > 3 Mio App-Downloads

Page 6: Coexisting of Android & Robots

Normal activity

Seite 6 | Coexisting of Android and Robots | Hasan Hosgel

Page 7: Coexisting of Android & Robots

Normal activity

Seite 7 | Coexisting of Android and Robots | Hasan Hosgel

do you like it?

Page 8: Coexisting of Android & Robots

Normal activity

Seite 8 | Coexisting of Android and Robots | Hasan Hosgel

do you like it?

a lot of boilerplate code

Page 9: Coexisting of Android & Robots

How to avoid this?

Seite 9 | Coexisting of Android and Robots | Hasan Hosgel

Page 10: Coexisting of Android & Robots

How to avoid this?

Seite 10 | Coexisting of Android and Robots | Hasan Hosgel

as the talk subject says RoboGuice

Page 11: Coexisting of Android & Robots

RoboGuice

Seite 11 | Coexisting of Android and Robots | Hasan Hosgel

DI & IOC Framework for Android

Source: http://roboguice.org

Page 12: Coexisting of Android & Robots

RoboGuice

Seite 12 | Coexisting of Android and Robots | Hasan Hosgel

DI & IOC Framework for Android

based on Google Guice no AOP (JSR-330 compatible)

Source: http://roboguice.org

Page 13: Coexisting of Android & Robots

RoboGuice

Seite 13 | Coexisting of Android and Robots | Hasan Hosgel

DI & IOC Framework for Android

based on Google Guice no AOP (JSR-330 compatible)

actual version 2.0

Source: http://roboguice.org

Page 14: Coexisting of Android & Robots

definition IOC & DI source: http://wikipedia.com

Seite 14 | Coexisting of Android and Robots | Hasan Hosgel

Dependency injection is a software design pattern that allows a choice of component to be made at run-time rather than compile time. This can be used, for example, as a simple way to load plugins dynamically or to choose mock objects in test environments vs. real objects in production environments.

In software engineering, Inversion of Control (IoC) is an object-oriented programming practice whereby the object coupling is bound at run time by an "assembler" object and is typically not knowable at compile time using static analysis.

Page 15: Coexisting of Android & Robots

definition IOC & DI source: http://wikipedia.com

Seite 15 | Coexisting of Android and Robots | Hasan Hosgel

Dependency injection is a software design pattern that allows a choice of component to be made at run-time rather than compile time. This can be used, for example, as a simple way to load plugins dynamically or to choose mock objects in test environments vs. real objects in production environments.

In software engineering, Inversion of Control (IoC) is an object-oriented programming practice whereby the object coupling is bound at run time by an "assembler" object and is typically not knowable at compile time using static analysis.

Spring Google Guice

EJB (> 3.0) JBoss Seam

Page 16: Coexisting of Android & Robots

What you need for RoboGuice?

Seite 16 | Coexisting of Android and Robots | Hasan Hosgel

Android project

RoboGuice 2.0

Guice 3.0 no AOP

javax.inject

Page 17: Coexisting of Android & Robots

Configuration

Seite 17 | Coexisting of Android and Robots | Hasan Hosgel

extend Robo* classes

Page 18: Coexisting of Android & Robots

Configuration

Seite 18 | Coexisting of Android and Robots | Hasan Hosgel

extend Robo* classes

create roboguice_modules.xml

Page 19: Coexisting of Android & Robots

Configuration

Seite 19 | Coexisting of Android and Robots | Hasan Hosgel

extend Robo* classes

create roboguice_modules.xml

create your AbstractModule

Page 20: Coexisting of Android & Robots

Configuration

Seite 20 | Coexisting of Android and Robots | Hasan Hosgel

extend Robo* classes

create roboguice_modules.xml

create your AbstractModule

configure the module in the xml

Page 21: Coexisting of Android & Robots

Injection Types

Seite 21 | Coexisting of Android and Robots | Hasan Hosgel

Page 22: Coexisting of Android & Robots

Injection Types

Seite 22 | Coexisting of Android and Robots | Hasan Hosgel

member injection

Page 23: Coexisting of Android & Robots

Injection Types

Seite 23 | Coexisting of Android and Robots | Hasan Hosgel

member injection

setter injection

Page 24: Coexisting of Android & Robots

injection types

Seite 24 | Coexisting of Android and Robots | Hasan Hosgel

member injection

setter injection

constructor injection

Page 25: Coexisting of Android & Robots

annotation types part 1

Seite 25 | Coexisting of Android and Robots | Hasan Hosgel

! @Inject

! standard Guice annotation

! @InjectView(resId)

! inject views after „setContentView()“ in „onCreate()“

! @InjectResource(resId)

! inject resource in „onCreate()“

! @InjectExtra(extraName)

! inject extra only in „onCreate()“ NOT „onNewIntent()“

! @InjectPreference(keyName)

! reads preference by keyName

! @InjectFragment(resId, tagName)

! inject the fragment to the resId with the tagName

Page 26: Coexisting of Android & Robots

annotation types part 2

Seite 26 | Coexisting of Android and Robots | Hasan Hosgel

! @ContentView(resId)

! set layout for activity/ fragment

! @Named(valueName)

! with the valueName a specific configuration can be done

! no annotation but related Provider<T>

! asynchronous injection, if the creation is expensive and not always used. The method #get() can be used

Page 27: Coexisting of Android & Robots

RoboGuiced activity

Seite 27 | Coexisting of Android and Robots | Hasan Hosgel

Page 28: Coexisting of Android & Robots

Normal activity

Seite 28 | Coexisting of Android and Robots | Hasan Hosgel

for comparison

Page 29: Coexisting of Android & Robots

RoboGuiced activity

Seite 29 | Coexisting of Android and Robots | Hasan Hosgel

much better & clearer

Page 30: Coexisting of Android & Robots

RoboGuice in Action

Seite 30 | Coexisting of Android and Robots | Hasan Hosgel

Page 31: Coexisting of Android & Robots

RoboGuice in Action

Seite 31 | Coexisting of Android and Robots | Hasan Hosgel

Live Coding...

Page 32: Coexisting of Android & Robots

Robotium

Seite 32 | Coexisting of Android and Robots | Hasan Hosgel

Test Framework for Android

similar to Selenium/ WebTest

actual version 3.2.1

Page 33: Coexisting of Android & Robots

What you need for Robotium?

Seite 33 | Coexisting of Android and Robots | Hasan Hosgel

robotium-solo-3.2.1

extend from ActivityInstrumentationTestCase2

instanciate Solo

finishInactiveActivities & finishOpenedActivities on solo in teardown

Page 34: Coexisting of Android & Robots

What you can do with Robotium?

Seite 34 | Coexisting of Android and Robots | Hasan Hosgel

! remote run of application/ black box tests

! click on view

! long click on view

! scroll

! search for text and view

! wait for text and view

! enter text

! send keys

! configure sleeper/ waiter? NO è use fork https://github.com/alosdev/robotium

Page 35: Coexisting of Android & Robots

Robotium in Action

Seite 35 | Coexisting of Android and Robots | Hasan Hosgel

Page 36: Coexisting of Android & Robots

Robotium in Action

Seite 36 | Coexisting of Android and Robots | Hasan Hosgel

Live Coding...

Page 37: Coexisting of Android & Robots

! clearer structure/ better API

! better testable/ test automation

! state of the art è proven in production (@IS24 since more than 1 year)

! good for libraries

Why this fuss?

| Coexisting of Android and Robots | Hasan Hosgel Seite 37

use RoboGuice & Robotium for Android

Page 38: Coexisting of Android & Robots

Dive into the topic & sources

Seite 38 | Coexisting of Android and Robots | Hasan Hosgel

! github with sample project of presentation:

! https://github.com/alosdev/amu-roboguice

! slideshare:

! http://www.slideshare.net/hosgel/coexisting-of-android-robots

! RoboGuice:

! http://roboguice.org/

! Robotium:

! http://robotium.org/

! deeper look into RoboGuice:

! http://www.blog.project13.pl/wp-content/uploads/2011/12/presentation.html

Page 39: Coexisting of Android & Robots

Thanks for your attention! Questions?

http://www.flickr.com/photos/peterjlambert/97671748/sizes/o/in/photostream/

Page 40: Coexisting of Android & Robots

www.immobilienscout24.de

Kontakt: ImmobilienScout24 Andreasstraße 10 10243 Berlin

Vielen Dank für Ihre Aufmerksamkeit!

Fon: 030/24301-11 00 Email: [email protected]. URL: www.immobilienscout24.de


Recommended