Test Session.GetReports by reference files. The idea
is to GetReports from the reference sessions files
so that we could know the expected results. It could
do extractly comparsions.
To achieve the goal,
1) create 5 directories of sessions files
2) copy reference files from 'test/test-dbus/cache'
to current xdg cache directory 'test-dbus/cache'.
3) calling 'GetReports' and compare returned results
with expected value.
This unit test covers below cases of GetReports:
1) start=0, index=0
2) start=0, index=1
3) start=0, index=0xFFFFFFFF
4) start=2, index=0xFFFFFFFF
5) start=5, index=0xFFFFFFFF
The case 4) will cause an integer overflow issue.
Thus nothing is returned, which is not expected.
The fix for this will be in the next commit.
Remove all reduntant 'cleanAllConfig' in TestSessionAPIsDummy.
The reason is that each unit test of this class
will create a new xdg directory before running.
The function 'setupFiles' is used to copy reference directory
trees from 'test/test-dbus' to 'xdg_root(./test-dbus)'. It
won't do copy unless own_xdg is enabled. Otherwise, user's
directories might be polluted.
This function is for those unit tests which are
hard(or impossbile) to do comparisons. To solve this
problem, we can create reference files in 'test/test-dbus'
and copy them to 'xdg_root' and compare expected results
with values returned from DBus server.
Currently 4 sub-directories are copied, but
maybe with different names, mappings are:
test/test-dbus ./test-dbus
sync4j .sync4j
data data
config config
cache cache
Since now TestSessionAPIsDummy is not only for config,
but also for other session APIs, change the server name
in this class from 'dummy-test-for-config-purpose' to
'dummy-test'. The server name hasn't conflicts because
new 'own_xdg/config' directory is created for unit tests
of this class.
The function was defined, but not part of the server implementation at
all. The order of the returned sessions is now defined in the
specification.
Note that the spec allows for *multiple* running sessions although
currently we only can have at most one.
We used to have the strings "your SyncML server account name" and
"your SyncML server password" hard-coded in the code which generated
templates. As Jussi pointed out, this is a problem for GUIs which have
to hide these strings from their users.
The purpose of these strings was to have them in configs in cases
where the user forgot to set them, as a reminder.
This path moves the strings into the command line config setup,
thus achieving both of these goals.
These operations do instantiate backends, but that should be possible
even if there is another active session using them. Because it is
useful for the sync-UI, let these two methods be called via the
read-only Server API.
I haven't added tests for them because that would create merge conflicts
with the "server-config" branch and shared configs. Should be added
later.
All sessions started in m_syncStatus = SYNC_IDLE state. The
transition from m_active = FALSE (= queueing) to m_active = TRUE
(= real "idle") was not announced via a "StatusChanged" signal.
Added a new SYNC_QUEUEING state. m_syncStatus starts in that state
and changes to idle together with sending the signal when the session
gets activated. I kept the m_active/setActive() part because it is
somewhat orthogonal to the state transitions and m_active is easier
to check than different states.
testSyncSecondSession is similar to testSecondSession: it creates two
sessions and checks that the second one becomes ready once the first
one is done. But instead of detaching from the first session after a
certain delay (as testSecondSession) does, the first session runs
a real sync, which deactivates it when the sync is done.
The DBusUtil.setUpSession() method was refactored so that it can be
used to create multiple sessions.
Remove signal handler in createSession() because callers do not expect
events getting record by the function, should the signal fire later on.
However, if the caller explicitly asks for it by indicating that it
does the waiting itself, then keep the handler in place.
The signal handlers were registered with the session path as object
path to match against, but the org.syncevolution.Server signals
are all sent with "org.syncevolution.Server" as path.
The signal handlers must match against the expected session path in
their own code.
The testSecondSession test only worked because the timeout fired
when the second session was indeed ready. Use the default timeout
which will correctly report the test as failed and fixed waiting
for second session becoming ready.
This is based on an observation by Yongsheng. The previous code set
SYNC_DONE when the Synthesis engine signaled the corresponding event.
This is too early, SyncEvolution then still has work to do.
The second point where SYNC_DONE was set was after the return of
SyncContext::sync(). Closer, but then there's still the connection
which might have to be shut down.
In contrast to Yongsheng's patch, this one here also takes into account
that shutting down the connection might throw an exception and sets
SYNC_DONE both in that and the normal shutdown code path.
Registered Python D-Bus signal handlers cannot be removed.
This had the undesired effect that when running multiple tests,
old signal handlers where still active and might have undesired
effects, like calling loop.quit() or recording events multiple
times (because both the old and new handler are invoked).
To solve this problem, DBusUtil.runTest() sets self.running = True
while the test is active. All signal handlers must check this
flag and not do anything if it is False.
Debugging such problems was harder than necessary because recording
the "quit_events" inside DBusUtil instances had the effect that the
records of previous signal handlers where not visible in the ensuing,
failing test.
Therefore this patch also turns the DBusUtil instance variables into
class variables which are shared by the tests. As a side effect, it is
no longer necessary to call DBusUtil.__init__. Instead the variables
are reset in runTest().
Calling arbitrary functions sometime in the future is implemented via
SIGALRM and code which multiplexes that single signal among several
different timouts. The signal is always set so that it triggers in
time for the closest timeout, kept in a heap.
The timeouts are sometimes used to call loop.quit(). There is no guarantee
that the process really is in loop.run() when SIGALRM fires. Therefore
timeouts are installed with glib.timeout_add() by default and if available.
With this change, the testSecondSession test works without glib Python
binding.
In addition, because the new alarm functionality works outside and
inside loop.quit(), it can be used to implement timeouts for
tests. These timeouts are mandatory and implemented by
DBusUtil.runTest(). The default is 5 seconds. It can be overridden
via a @timeout(seconds) function decorator which sets the non-default
timeout in the "timeout" attribute of the test function.
Getting to that function instance in runTest() is a bit tricky. It is
done by looking up the TestCase.id() in the global name space, minus
the "__main__." part which would prevent finding the function.
When running all tests I noticed that the test runner showed
the two testSync methods with their method and class name. Not sure
whether this was because of the missing docstring or the duplication
of the method name; renamed the methods and added a description to
the test instead of the test suite.
The TestSessionAPIsReal.testSync() had failed with a description
that pointed towards the syncevo-dbus-server getting killed prematurely.
In an attempt to track this down I added a check of self.quit_events,
but then the test succeeded.
also remove the "manual services list": everything is in the same
list now.
There are some minor focusing issues (scrolling to the correct
spot in the list), but otherwise it's working.
Cherry-picked from jku-single-window
service dialog no longer exists. The contents are now shown
in the service list: service list items are SyncConfigWidgets
that expand to show the "dialog".
The change is not complete yet: e.g "Save config" does not work yet.
This is a merge from
commit 'a30e5da64f96f6d54fc402a6da0fb44814fa7ecd' into jku-dbus-update
Conflicts:
src/gtk-ui/Makefile.am
src/gtk-ui/sync-ui-config.h
src/gtk-ui/sync-ui.c
Throwing the exception about an unsupported transport must be
reached also for OBEX/Bluetooth URLs when ENABLE_BLUETOOTH is off.
Otherwise the function is left without valid return code.
Service settings window still exists, but this is the first step
in getting rid of it, and including the settings in the service
list.
There is now a dependency on NbtkGtk when building with moblin ui
1) Add quotes for the source name when raising the error
message
2) Change the error message when config name is not given:
"Template or server name must be given"
-->
"Server name must be given"
Add 4 unit tests for Session.GetReports:
1) Test the error is reported when the server name is empty
2) Test when the given server does not exist
3) Test when the given server has no reports. Also covers
boundaries
4) Test when the given server exists and reports are
returned correctly. Also covers boundaries
For unit test 4), we change TestDBusSync to
'TestSessionAPIsReal'.
The new class is used to test those unit tests of
session APIs, depending on doing sync. Thus we
need a real server configuration to confirm sync
could be run successfully.
Add 4 unit tests for Session.GetDatabases:
1) Test the error is reported when the server name is empty
2) Test the error is reported when the given server does
not exist
3) Test nothing is returned when the given server exists
but it has no given source
4) Test when the given server exists and a correct source.
All work correctly.
Change 'TestDBusSessionConfig' to 'TestSessionAPIsDummy'
to let this class also cover other Session APIs.
Add 5 unit tests for Session.CheckSource:
1) Test the error is reported when the server name is empty
2) Test the error is reported when the given server does
not exist
3) Test the error is reported when the given server exists
but it has no given source
4) Test the error is reported when the given server exists
but the given source with an invalid evolutionsource
5) Test when the given server exists and a correct source.
Then all work correctly.
For detail, please see test cases design.
Add this class is to test APIs that the correct
errors are reported when the server name is empty.
Also, add 2 unit tests to cover this case for
GetConfig/SetConfig when the server name is empty.
Add ENABLE_OBEX wrapper with the two files, so that it will include nothing if
no libopenobex is installed.
Include OBEX header after Bluetooth header to avoid a redefinition error.