Commit graph

2088 commits

Author SHA1 Message Date
Zhu, Yongsheng
896246acf4 D-Bus testing: add testGetReportsByRef in TestSessionAPIsDummy
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.
2009-11-20 13:51:16 +01:00
Zhu, Yongsheng
423fc0378f D-Bus testing: change comment for testGetReportsNoConfig
Changes are:
"Test when the given server has no reports."
-->
"Test nothing is gotten when the given server doesn't exist."
2009-11-20 13:51:16 +01:00
Zhu, Yongsheng
e61d7fd1cb D-Bus testing: remove reduntant 'cleanAllConfig'
Remove all reduntant 'cleanAllConfig' in TestSessionAPIsDummy.
The reason is that each unit test of this class
will create a new xdg directory before running.
2009-11-20 13:51:15 +01:00
Zhu, Yongsheng
45d6ac157f D-Bus testing: add 'setupFiles' function in DBusUtil
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
2009-11-20 13:51:15 +01:00
Zhu, Yongsheng
c3787a6bb8 D-Bus testing: change the server name in TestSessionAPIsDummy
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.
2009-11-20 13:48:55 +01:00
David Bremner
e2290982bf Merge branch 'upstream' 2009-11-20 08:02:39 -04:00
David Bremner
0e341da74d add new upstream version to changelog 2009-11-20 07:56:18 -04:00
David Bremner
93a1a3c05c bump upstream tag 2009-11-20 07:54:32 -04:00
Jussi Kukkonen
d1dd85b72a fix syncevolution exception names in dbus wrapper 2009-11-20 11:22:23 +02:00
Jussi Kukkonen
da7458ad49 gtk-ui: implement enabling/disabling sources in main view 2009-11-20 11:19:56 +02:00
Patrick Ohly
d5e58fd0a9 syncevo-dbus-server: implement Server.GetSessions() (MB #8061)
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.
2009-11-20 09:36:26 +01:00
Jussi Kukkonen
12599210a6 gtk-ui: remove old service icon before adding new one 2009-11-20 00:50:29 +02:00
Jussi Kukkonen
7a12d8fb5e gtk-ui: set ui state to ok when config is received 2009-11-20 00:39:19 +02:00
Jussi Kukkonen
ed016a23c0 gtk-ui: implement saving config 2009-11-20 00:27:33 +02:00
Jussi Kukkonen
10d31bd9c5 fix double free in dbus C wrapper 2009-11-20 00:27:00 +02:00
Patrick Ohly
0bfc0a4bb7 client-test: added remoteIdentifier + PeerIsClient
The two properties were added to the config, but the test wasn't
updated accordingly.
2009-11-19 16:33:33 +01:00
Patrick Ohly
e14115cf64 username/password: empty in templates
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.
2009-11-19 16:30:46 +01:00
Jussi Kukkonen
7a1cb2b8cf gtk-ui: only show ConsumerReady services 2009-11-19 16:00:07 +02:00
Jussi Kukkonen
ed4693b413 gtk-ui: make configuration widgets handle their state better
SyncConfigurationWidget now has construction properties
"has-template" and "configured" to represent the state on the server
2009-11-19 15:34:45 +02:00
Patrick Ohly
01cbcd8acb D-Bus API + syncevo-dbus-server: added Server.CheckSource()/GetDatabases() (MB #8091)
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.
2009-11-19 14:07:23 +01:00
Patrick Ohly
f3b339ef00 syncevo-dbus-server: StatusChanged "idle" was not sent
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.
2009-11-19 13:44:22 +01:00
Jussi Kukkonen
3044f24d9c gtk-ui: improve SyncConfigWidget, don't run a session all the time 2009-11-19 13:25:50 +02:00
Patrick Ohly
bd6687bc9b D-Bus testing: added testSyncSecondSession
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.
2009-11-19 12:09:30 +01:00
Patrick Ohly
9e3cb6c6a9 D-Bus testing: SessionChanged signal handling was wrong
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.
2009-11-19 11:37:14 +01:00
Patrick Ohly
db9a5b5134 syncevo-dbus-server: send SYNC_DONE status after shutting down connection
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.
2009-11-19 10:07:47 +01:00
Patrick Ohly
ac1c3c032c D-Bus testing: only react to D-Bus signals while the test runs
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().
2009-11-19 10:05:24 +01:00
Patrick Ohly
79c55dc26a D-Bus testing: added glib independent timeouts
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.
2009-11-18 23:00:19 +01:00
Jussi Kukkonen
a490991edb gtk-ui: re-implement service configuration view
Configurations are displayed, buttons don't work yet
2009-11-18 16:18:27 +02:00
Jussi Kukkonen
e0c0eb51bd gtk-ui: more coverage for new dbus api
SyncConfigWidget is now the only thing with non-implemented
parts.
2009-11-18 12:58:08 +02:00
Patrick Ohly
b6fda4d24d D-Bus testing: avoid duplicate testSync methods, minor improvements
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.
2009-11-18 11:06:05 +01:00
Jussi Kukkonen
bc1380ad8b Merge remote branch 'origin/jku-single-window' into jku-dbus-update 2009-11-17 15:46:58 +02:00
Jussi Kukkonen
fa13cd5a2f gtk-ui: add automatic expansion to service list
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
2009-11-17 14:55:48 +02:00
Patrick Ohly
cf53493f14 SyncContext::createTransportAgent(): removed unused agent variable
The empty smart pointer is no longer needed.
2009-11-17 13:36:54 +01:00
Jussi Kukkonen
3e1dea5150 implement the service list contents as widgets
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
2009-11-17 14:32:11 +02:00
Jussi Kukkonen
1de14bfb6f fix build problems, fix compiler warnings 2009-11-17 13:56:24 +02:00
Patrick Ohly
1ddbffd503 OBEX transport: fix compiler error when OBEX transport is off
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.
2009-11-17 12:48:10 +01:00
Jussi Kukkonen
1e2c7f094a gtk-ui: use NbtkGtkExpander in service list
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
2009-11-17 13:36:31 +02:00
Zhu, Yongsheng
51a29483e3 syncevo-dbus-server: change error message for getReports
Change the error message when config name is not given:
"Template name must be given"
-->
"Server name must be given"
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
fee816191b syncevo-dbus-server: change error message for getDatabases
Change the error message when config name is not given:
"Template or server name must be given"
-->
"Server name must be given"
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
9e1cfc43c5 syncevo-dbus-server: change error message of checkSource
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"
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
05a0c041db syncevo-dbus-server: change error message for setConfig
Change the error message when config name is not given:
"Template name must be given"
-->
"Server name must be given"
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
497d45b58c syncevo-dbus-server: change error message for getConfig
Change the error message when config name is not given:
"Server name must be given"
-->
"Template or server name must be given"
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
99459042b9 D-Bus testing: add unit tests for Session.GetReports
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.
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
934cd8028c D-Bus testing: add unit tests for Session.GetDatabases
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.
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
a0572c148e D-Bus testing: add unit tests for Session.CheckSource
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.
2009-11-17 10:56:00 +01:00
Zhu, Yongsheng
9f822619ed D-Bus testing: add TestSessionAPIsEmptyName class
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.
2009-11-17 10:55:59 +01:00
Zhu, Yongsheng
c8582081d9 D-Bus testing: change comments for unit tests of config
refine comments for some unit tests of config to
make them clear to be understood.
2009-11-17 10:55:59 +01:00
Jussi Kukkonen
4f22df2836 implement first phase of "single window mode"
* implement "settings" in MuxWindow
* use settings in sync ui: settings widgets are the same as in
  services window in normal gtk
2009-11-17 11:53:28 +02:00
Jussi Kukkonen
89005c2770 gtk-ui: only sync enabled and locall supported sources 2009-11-17 11:52:31 +02:00
Chen Congwu
b3a88ef0d6 ObexTransportAgent: compiling fixes MB#5188
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.
2009-11-17 17:04:37 +08:00