I have made the following changes intended for : CE:Apps:MTF / qmlnotes Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below.
https://build.pub.meego.com//request/show/5941 Thank You, rbraakman [This message was auto-generated] --- Request # 5941: Messages from BOSS: State: review at 2012-08-20T20:31:48 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: home:rbraakman / qmlnotes -> CE:Apps:MTF / qmlnotes changes files: -------------- --- qmlnotes.changes +++ qmlnotes.changes @@ -0,0 +1,3 @@ +* Mon Aug 20 2012 Richard Braakman <[email protected]> - 0.4.4 +- [tests] Create test case framework and sample test. + old: ---- qmlnotes-0.3.2.tar.bz2 new: ---- qmlnotes-0.4.4.tar.bz2 spec files: ----------- --- qmlnotes.spec +++ qmlnotes.spec @@ -3,7 +3,7 @@ Name: qmlnotes Summary: Note-taking application -Version: 0.3.2 +Version: 0.4.4 Release: 1 Group: Applications/System License: GPLv2+ @@ -18,6 +18,17 @@ %description Note-taking application using Qt Quick +%package tests +Summary: Unit tests for the note-taking application +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: qttas-server +Requires: rubygem-testability-driver-qt-sut-plugin +Requires: ruby + +%description tests +This package contains unit tests to be run with TDriver and testrunner-lite. + %prep %setup -q @@ -42,3 +53,7 @@ %defattr(-,root,root,-) %{_bindir}/qmlnotes %{_datadir}/applications/qmlnotes.desktop + +%files tests +%defattr(-,root,root,-) +%{_datadir}/%{name}-tests/ other changes: -------------- ++++++ qmlnotes-0.3.2.tar.bz2 -> qmlnotes-0.4.4.tar.bz2 --- .gitignore +++ .gitignore @@ -0,0 +1,6 @@ +qmlnotes +Makefile +*.o +moc_*.cpp +qrc_*.cpp +tests/tests.xml --- qml/Note.qml +++ qml/Note.qml @@ -8,11 +8,13 @@ id: note property string name: '' + property alias text: editor.text + onNameChanged: { if (name == '' || editor.busy) return; editor.busy = true; - editor.text = backend.read_note(name); + text = backend.read_note(name); editor.busy = false; } --- qml/NoteRing.qml +++ qml/NoteRing.qml @@ -34,6 +34,7 @@ Note { id: note name: model.name + property int index: model.index width: notering.width; height: notering.height fontScale: globalFontScale --- qmlnotes.pro +++ qmlnotes.pro @@ -40,3 +40,10 @@ } else { warning("qdeclarative-boostable not available; startup times will be slower") } + +tests.path = $$INSTALL_ROOT/usr/share/qmlnotes-tests +tests.files = tests/tests.xml tests/*.rb tests/notes.sh +tests.extra = (cd tests && ./gen_tests_xml.sh >$$OUT_PWD/tests/tests.xml) +tests.CONFIG = no_check_exist + +INSTALLS += tests --- rpm/qmlnotes.spec +++ rpm/qmlnotes.spec @@ -18,6 +18,17 @@ %description Note-taking application using Qt Quick +%package tests +Summary: Unit tests for the note-taking application +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: qttas-server +Requires: rubygem-testability-driver-qt-sut-plugin +Requires: ruby + +%description tests +This package contains unit tests to be run with TDriver and testrunner-lite. + %prep %setup -q @@ -42,3 +53,7 @@ %defattr(-,root,root,-) %{_bindir}/qmlnotes %{_datadir}/applications/qmlnotes.desktop + +%files tests +%defattr(-,root,root,-) +%{_datadir}/%{name}-tests/ --- tests +++ tests +(directory) --- tests/gen_tests_xml.sh +++ tests/gen_tests_xml.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +cat <<'EOT' +<?xml version='1.0' encoding='UTF-8'?> +<testdefinition version='0.1'> + <suite name='qmlnotes-tests' domain='Applications' type='Functional'> + <set name='functional_tests' description='Functional tests' feature='Notes'> + <pre_steps> + <step>qttasserver &</step> + <step expected_result='0'>/usr/share/qmlnotes-tests/notes.sh stash</step> + </pre_steps> +EOT + +for file in test_*.rb; do + if [ "$file" = "qmlnotes_tester.rb" ]; then continue; fi + + desc=$(grep '^#DESCRIPTION:' $file | sed -e 's/^#DESCRIPTION: //') + name=${file%.rb} + name=${name#test_} + cat <<EOT + <case name='${name}' description='$desc'> + <step expected_result='0'>ruby /usr/share/qmlnotes-tests/$file</step> + </case> +EOT +done + +cat <<'EOT' + <post_steps> + <step expected_result='0'>/usr/share/qmlnotes-tests/notes.sh unstash</step> + </post_steps> + <environments> + <scratchbox>true</scratchbox> + <hardware>true</hardware> + </environments> + </set> + </suite> +</testdefinition> +EOT --- tests/notes.sh +++ tests/notes.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -e + +NOTES_DIR="$HOME/Notes" +STASH_DIR="$HOME/Notes.test-stash" + +DB_DIR="$HOME/.local/share/data/QML/OfflineStorage/Databases" +# "qmlnotes" as encoded by QML OfflineStorage +DB_NAME="1ad6e6d9437aa20aeb62cc788dba5ea2" + +NOTES_INI="$DB_DIR/$DB_NAME.ini" +NOTES_STASH_INI="$DB_DIR/$DB_NAME.test_stash.ini" +NOTES_DB="$DB_DIR/$DB_NAME.sqlite" +NOTES_STASH_DB="$DB_DIR/$DB_NAME.test_stash.sqlite" + +STASH_FLAG="$HOME/.stashed_notes" + +if [ "x$1" = "xstash" ]; then + # clear the way for a test run + if [ -d "$NOTES_DIR" ]; then + if [ -d "$STASH_DIR" ]; then + rm -rf "$NOTES_DIR" + else + mv "$NOTES_DIR" "$STASH_DIR" + fi + fi + if [ -f "$NOTES_INI" ]; then + if [ -f "$NOTES_STASH_INI" ]; then + rm -f "$NOTES_STASH_INI" "$NOTES_STASH_DB" + else + mv "$NOTES_INI" "$NOTES_STASH_INI" + mv "$NOTES_DB" "$NOTES_STASH_DB" + fi + fi + touch "$STASH_FLAG" + +elif [ "x$1" = "xunstash" ]; then + # restore the pre-stash state if possible + if [ -f "$STASH_FLAG" ]; then + rm -rf "$NOTES_DIR" + rm -f "$NOTES_INI" "$NOTES_DB" + rm "$STASH_FLAG" + fi + if [ -d "$STASH_DIR" ]; then + rm -rf "$NOTES_DIR" + mv "$STASH_DIR" "$NOTES_DIR" + fi + if [ -f "$NOTES_STASH_INI" ]; then + mv "$NOTES_STASH_INI" "$NOTES_INI" + mv "$NOTES_STASH_DB" "$NOTES_DB" + fi +fi --- tests/qmlnotes_tester.rb +++ tests/qmlnotes_tester.rb @@ -0,0 +1,67 @@ +require 'tdriver' +include TDriverVerify + +class QmlnotesTester + + def initialize + @sut = TDriver.sut(:sut_qt) + @app = @sut.run(:name => 'qmlnotes', :restart_if_running => true, + :arguments => '-fullscreen,-testability') + @timeout = nil + end + + def kill + @app.close(:force_kill => true, :check_process => true) + end + + def restart + @app.close(:check_process => true) + @app = @sut.run(:name => 'qmlnotes', + :arguments => '-fullscreen,-testability') + end + + def _horiz_overlap(a, b) + al = a['x'].to_i + ar = a['x'].to_i + a['width'].to_i + bl = b['x'].to_i + br = b['x'].to_i + b['width'].to_i + # note that the 'r' values are just past the end of the object + return (al >= bl && al < br) || (ar > bl && ar <= br) + end + + def verify_empty + verify_equal('', @timeout, "expected empty Note page") { + @app.Note(:x => @app.NoteRing['x'], :y => @app.NoteRing['y'])['text'] + } + end + + def verify_index(index) + verify(@timeout, "expected current note #{index}") { + @app.NoteRing.QDeclarativeListView(:currentIndex => index.to_s) + } + verify(@timeout, "expected current note to be in view") { + listview = @app.NoteRing.QDeclarativeListView + _horiz_overlap(listview.Note(:index => index.to_s), listview) + } + end + + def _flick_note(direction) + # Even if the currentIndex gets reset to its original value (which can + # happen if it wraps around a size-1 ring), it should at least briefly + # take on a new value during the flick. + @app.NoteRing.QDeclarativeListView.verify_signal(3, 'currentIndexChanged()', + "Expected current index to change after flick") { + @app.NoteRing.QDeclarativeListView.gesture(direction, 0.5, 300, + :use_tap_screen => true) + } + end + + def flick_note_left + _flick_note(:Left) + end + + def flick_note_right + _flick_note(:Right) + end + +end --- tests/test_initial_empty_note_ring.rb +++ tests/test_initial_empty_note_ring.rb @@ -0,0 +1,15 @@ +#DESCRIPTION: Notes app starts with empty notes in a ring +require File.expand_path(File.join(File.dirname( __FILE__ ), 'qmlnotes_tester')) + +tester = QmlnotesTester.new + +tester.verify_empty +tester.verify_index(1) +tester.flick_note_left +tester.verify_empty +tester.verify_index(1) +tester.flick_note_right +tester.verify_empty +tester.verify_index(1) + +tester.kill
