QA SoftVision Team/Mobile/Writing tests: Difference between revisions

m
Bug 1082602
m (Bug 1082602)
 
(5 intermediate revisions by one other user not shown)
Line 13: Line 13:
* If you already have the sources downloaded update to the lates version by running the command in the sources directory:
* If you already have the sources downloaded update to the lates version by running the command in the sources directory:
  hg pull -u
  hg pull -u
* Make the build by running in '''superuser''' (sudo su) and make sure the [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Update_Android_SDK PATH] variable is updated with the Android SDK location:
* Make the build by running:
  make -f client.mk
  make -f client.mk
* Create a new file named "test" followed by the test name and with the extention "java.in" : for e.g. ''testBookmarks.java.in''
* Create a new file named "test" followed by the test name and with the extention "java.in" : for e.g. ''testBookmarks.java.in''
Line 168: Line 168:
url
url
</pre>
</pre>
= Gecko Events you can wait for =
* There are a set of messages sent from Gecko to Java to signal different actions
* Also Java can register observers to catch changes to deferent actions
* Here is a list of Gecko Events on which you can create EventExpectors and block until the message is received
<pre>
Addons:Change
Addons:All - shown when sending all addons to java as a json
Addons:FetchAll - get the state of all addons
Browser:Quit
Browser:ZoomToRect - zoom to element (viewport if the element is to large)
Browser:ZoomToPageWidth
Campaign:Set - Update the prefs for this session - related to distribution
CharEncoding:Data
CharEncoding:Get
CharEncoding:Set
CharEncoding:State
Content:LoadError
Content:PageShow
Content:ReaderEnabled
Content:StateChange - change in network state
Content:LocationChange - change of location
Content:SecurityChange
DesktopMode:Change
Distribution:Set
Distribution:Set:OK
DOMFullScreen:Start
DOMFullScreen:Stop
DOMContentLoaded
DOMLinkAdded
DOMMetaAdded
DOMModalDialogClosed
DOMUpdatePageReport
DOMTitleChanged
DOMWindowClose
DOMWillOpenModalDialog
Doorhanger:Add
Doorhanger:Remove
Doorhanger:Reply
Feedback:LastUrl
Feedback:OpenPlayStore
Feedback:MaybeLater
FilePicker:Show
FormAssist:Hide - shown when hide request given
FormAssist:AutoComplete - shown when autocomplete is displayed
FormAssist:Blocklisted
FormAssist:Hidden - shown when the form assist has been hidden
FormAssist:ValidationMessage - shown when a vaildation message is displayed
FormHistory:Init - initialize form history db on update
FullScreen:Exit
Gecko:Ready
Gesture:CancelTouch
Gesture:DoubleTap
Gesture:LongPress
Gesture:Scroll
Gesture:ScrollAck
Gesture:SingleTap
Link:Favicon
Link:Feed
Menu:Add
Menu:Clicked
Menu:Update
Menu:Remove
MozApplicationManifest
MozMagnifyGesture
MozScrolledAreaChanged
nsPref:changed
OrderedBroadcast:Send
pageshow
Panning:Override
Panning:CancelOverride
PanZoom:StateChange
Passwords:Init - initialize passwords db on update
Permissions:Data
Prompt:Show
PluginBindingAttached
Pref:Change
Preferences:Get
Preferences:Set
Preferences:Observe
Preferences:RemoveObservers
PrivateBrowsing:Data
Reader:Add
Reader:Added
Reader:FaviconRequest
Reader:GoToReadingList
Reader:Remove
Reader:Share
robocop:scroll
SaveAs:PDF
Sanitize:ClearData
Sanitize:ClearHistory
Sanitize:Finished
scroll
ScrollTo:FocusedInput
SearchEngines:Data
SearchEngines:Get
Session:Back
Session:Forward
Session:Reload
Session:RestoreEnd
Session:ShowHistory
Session:StatePurged
Session:Stop
SessionHistory
Share:Text
SharedPreferences:Set
SharedPreferences:Observe
Shortcut:Remove
Tab:Close
Tab:Closed
Tab:HasTouchListener
Tab:Load
Tab:Select
Tab:Selected
Tab:ViewportMetadata
Telemetry:Add
Telemetry:Gather
TextSelection:HideHandles
TextSelection:PositionHandles
TextSelection:ShowHandles
Toast:Show
ToggleChrome:Focus
ToggleChrome:Show
ToggleChrome:Hide
Viewport:Change
Viewport:Flush
Viewport:FixedMarginsChanged
Wallpaper:Set
WebApps:Open
WebApps:PreInstall
WebApps:PostInstall
Window:Resize
</pre>


= Basic code sequences to do different actions =
= Basic code sequences to do different actions =
Line 284: Line 419:
* You can use mAsserter.dumpLog(Sting) or mAsserter.ok(true, Sting, String) to print any string or value of any variable
* You can use mAsserter.dumpLog(Sting) or mAsserter.ok(true, Sting, String) to print any string or value of any variable
* Note that you will need to cast the variable to String in order to print it: String.valueOf(Variable)
* Note that you will need to cast the variable to String in order to print it: String.valueOf(Variable)
= Substituting mSolo.sleep =
* Don't use sleep unless absolutely necessary
* It's ok to use sleep while creating the test but at the end try and substitute it
* Here are some alternatives:
** waitForText(String waitText)
** waitForEnabledText(String waitText)
** blockForEvent/ blockForEventData - gecko event expecters
** waitForCondition
** waitForTest
** waitForPaint
** waitForView(View view)
** waitForView(View view, int timeout, boolean scroll)
** waitForDialogToOpen()
** waitForDialogToClose()
** waitForView(int id)
** waitForView(int id, int minimumNumberOfMatches, int timeout)
** waitForView(int id, int minimumNumberOfMatches, int timeout, boolean scroll)
** waitForActivity(name)
** waitForActivity(Class<? extends Activity> activityClass)
** waitForActivity(Class<? extends Activity> activityClass, int timeout)


= Updating your test directory =
= Updating your test directory =
Line 296: Line 451:
<pre>
<pre>
cd objdir
cd objdir
sudo make -C build/mobile/robocop/
make -C build/mobile/robocop/
sudo make package </pre>
make package </pre>


= Creating a diff patch file =
= Creating a diff patch file =
Line 392: Line 547:
  hg push -f -rtip ssh://<user>@hg.mozilla.org/try/
  hg push -f -rtip ssh://<user>@hg.mozilla.org/try/


* This will push the changes and will give you a tbpl link to your push
* This will push the changes and will give you a Treeherder link to your push
* When the building process for the test build will start you will also receive an email with the push info
* When the building process for the test build will start you will also receive an email with the push info


canmove, Confirmed users
1,126

edits