8

Click here to load reader

Introduzione ad Autopilot

Embed Size (px)

DESCRIPTION

Introduzione al test di Ubuntu usando Autopilot

Citation preview

Page 1: Introduzione ad Autopilot

Q u a l i t y i s t h e W o r d !Q u a l i t y i s t h e W o r d !

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 2: Introduzione ad Autopilot

S e t t i n g u p y o u r s y s t e mS e t t i n g u p y o u r s y s t e m

# Download del codice sorgente di unity$ bzr branch lp:unity

# Installazione pacchetti necessari$ sudo apt-get install python-autopilot

# Testare codice on-the-edge$ sudo add-apt-repository \ ppa:unity-team/staging

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 3: Introduzione ad Autopilot

R u n n i n g t h e t e s t sR u n n i n g t h e t e s t s# Entrare nella directory di unity$ cd ~/my-source-code/unity

# Esportare la variabile PYTHONPATH$ export PYTHONPATH=$PWD/tests/autopilot

# Avviare i test$ autopilot run unity

# Avviare un test specifico$ autopilot run \ unity.tests.test_panel.PanelIndicatorEntry*

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 4: Introduzione ad Autopilot

I n s p e c t i n g U n i t yI n s p e c t i n g U n i t y$ autopilot vis

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 5: Introduzione ad Autopilot

T e s t E x a m p l eT e s t E x a m p l e

// Inherit from unity::debug::Introspectable

void PanelIndicatorEntryView::AddProperties(GVariantBuilder* builder){ variant::BuilderWrapper(builder) .add(GetAbsoluteGeometry()) .add("entry_id", GetEntryID()) .add("name_hint", entry_->name_hint()) .add("type", entry_->type_name()) .add("priority", entry_->priority()) .add("label", GetLabel()) .add("label_sensitive", IsLabelSensitive()) .add("label_visible", IsLabelVisible()) .add("icon_sensitive", IsIconSensitive()) .add("active", proxy_->active()) .add("menu_x", proxy_->geometry().x) .add("menu_y", proxy_->geometry().y)); // ecc...}

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 6: Introduzione ad Autopilot

T e s t E x a m p l eT e s t E x a m p l edef test_menu_opens_on_click(self): """Tests that clicking on a menu entry, opens a menu.""" self.open_new_application_window("Calculator") refresh_fn = lambda: len(self.panel.menus.get_entries()) self.assertThat(refresh_fn, Eventually(GreaterThan(0))) menu_entry = self.panel.menus.get_entries()[0]

self.mouse_open_indicator(menu_entry)

self.assertThat(menu_entry.active, Eventually(Equals(True))) self.assertThat(menu_entry.menu_x, Eventually(Equals(menu_entry.x))) self.assertThat(menu_entry.menu_y, Eventually(Equals(self.panel.height)))

def mouse_open_indicator(self, indicator): """This is an utility function that safely opens an indicator.""" if not isinstance(indicator, IndicatorEntry): raise TypeError("Window must be a IndicatorEntry")

indicator.mouse_click() self.addCleanup(self.panel.move_mouse_below_the_panel) self.addCleanup(self.keyboard.press_and_release, "Escape") self.assertThat(indicator.active, Eventually(Equals(True)))

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 7: Introduzione ad Autopilot

Documentazione e tutorial:

● http://unity.ubuntu.com/autopilot/

● https://wiki.ubuntu.com/Unity/QA/Autopilot

R T F M !R T F M !

Marco Trevisan (Treviño) – [email protected]

Ubuntu-it meeting 2012

U n i t y , t e s t i n g w i t h A u t o p i l o t

Page 8: Introduzione ad Autopilot

Q u e s t i o n t i m eQ u e s t i o n t i m e

GRAZIE!Ping me: Trevinho @ Freenode

Ubuntu-it meeting 2012

Marco Trevisan (Treviño) – [email protected]

U n i t y , t e s t i n g w i t h A u t o p i l o t