[geary/wip/794174-conversation-monitor-max-cpu: 2/4] Tidy up unit test infrastructure and mock classes.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/794174-conversation-monitor-max-cpu: 2/4] Tidy up unit test infrastructure and mock classes.
- Date: Sat, 24 Mar 2018 03:15:23 +0000 (UTC)
commit de352a74ec1ea35eff4e59387b42ee14d9b93fb5
Author: Michael James Gratton <mike vee net>
Date: Fri Mar 9 11:58:02 2018 +1100
Tidy up unit test infrastructure and mock classes.
* test/api/*.vala: Renamed files that contained mock objects to *-mock.vala,
not *-test.vala.
* test/testcase.vala: Renamed to test-case.vala for consistency, remove
TestCase class from Gee package since that's really not true. Clean up
code for consistency.
* test/meson.build, test/CMakeLists.txt: Split TestCase compilation out
into a separate test lib.
test/CMakeLists.txt | 47 +++++++++++++---
.../application/geary-configuration-test.vala | 2 +-
.../components/client-web-view-test-case.vala | 2 +-
test/client/components/client-web-view-test.vala | 2 +-
...y-account-test.vala => geary-account-mock.vala} | 0
test/engine/api/geary-attachment-test.vala | 2 +-
...-test.vala => geary-email-identifier-mock.vala} | 0
...-test.vala => geary-email-properties-mock.vala} | 0
test/engine/api/geary-engine-test.vala | 2 +-
...ary-folder-test.vala => geary-folder-mock.vala} | 0
...-path-test.vala => geary-folder-path-mock.vala} | 0
test/engine/app/app-conversation-set-test.vala | 2 +-
test/engine/app/app-conversation-test.vala | 2 +-
.../engine/imap-engine/account-processor-test.vala | 2 +-
.../imap/command/imap-create-command-test.vala | 2 +-
.../response/imap-namespace-response-test.vala | 2 +-
.../imap/transport/imap-deserializer-test.vala | 2 +-
test/engine/mime-content-type-test.vala | 2 +-
test/engine/rfc822-mailbox-address-test.vala | 2 +-
test/engine/rfc822-mailbox-addresses-test.vala | 2 +-
test/engine/rfc822-message-data-test.vala | 2 +-
test/engine/rfc822-message-test.vala | 2 +-
test/engine/rfc822-utils-test.vala | 2 +-
test/engine/util-html-test.vala | 2 +-
test/engine/util-idle-manager-test.vala | 2 +-
test/engine/util-inet-test.vala | 2 +-
test/engine/util-js-test.vala | 2 +-
test/engine/util-string-test.vala | 2 +-
test/engine/util-timeout-manager-test.vala | 2 +-
test/meson.build | 56 ++++++++++++--------
test/{testcase.vala => test-case.vala} | 39 +++++++------
31 files changed, 116 insertions(+), 72 deletions(-)
---
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 16efeb0..40d161b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -2,17 +2,26 @@
# Copyright 2016 Software Freedom Conservancy Inc.
# Copyright 2016 Michael Gratton <mike vee net>
+set(TEST_LIB_SRC
+ test-case.vala
+)
+
set(TEST_ENGINE_SRC
test-engine.vala
- testcase.vala # Based on same file in libgee, courtesy Julien Peeters
- engine/api/geary-account-test.vala
+ # These should be included in the test lib sources, but we can't
+ # since that would make the test lib depend on geary-engine.vapi,
+ # and the engine test sute needs to depend
+ # geary-engine_internal.vapi, which leads to duplicate symbols when
+ # linking
+ engine/api/geary-account-mock.vala
+ engine/api/geary-email-identifier-mock.vala
+ engine/api/geary-email-properties-mock.vala
+ engine/api/geary-folder-mock.vala
+ engine/api/geary-folder-path-mock.vala
+
engine/api/geary-attachment-test.vala
engine/api/geary-engine-test.vala
- engine/api/geary-email-identifier-test.vala
- engine/api/geary-email-properties-test.vala
- engine/api/geary-folder-test.vala
- engine/api/geary-folder-path-test.vala
engine/app/app-conversation-test.vala
engine/app/app-conversation-set-test.vala
engine/imap/command/imap-create-command-test.vala
@@ -35,7 +44,6 @@ set(TEST_ENGINE_SRC
set(TEST_CLIENT_SRC
test-client.vala
- testcase.vala # Based on same file in libgee, courtesy Julien Peeters
client/application/geary-configuration-test.vala
client/components/client-web-view-test.vala
@@ -65,6 +73,12 @@ pkg_check_modules(DEPS REQUIRED
libxml-2.0
)
+set(TEST_LIB_PACKAGES
+ gee-0.8
+ gio-2.0
+ glib-2.0
+)
+
set(TEST_ENGINE_PACKAGES
gee-0.8
gio-2.0
@@ -102,6 +116,7 @@ set_property(SOURCE ${RESOURCES_C} PROPERTY GENERATED TRUE)
set(VALAC_OPTIONS
--vapidir=${CMAKE_BINARY_DIR}/src
+ --vapidir=${CMAKE_BINARY_DIR}/test
--vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
--metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata
--target-glib=${TARGET_GLIB}
@@ -113,10 +128,23 @@ set(VALAC_OPTIONS
${EXTRA_VALA_OPTIONS}
)
+vala_precompile(TEST_LIB_VALA_C test-lib
+ ${TEST_LIB_SRC}
+PACKAGES
+ ${TEST_LIB_PACKAGES}
+OPTIONS
+ --header=test-lib.h
+ --vapi=test-lib.vapi
+ ${VALAC_OPTIONS}
+)
+
+add_library(test-lib STATIC ${TEST_LIB_VALA_C})
+
vala_precompile(TEST_ENGINE_VALA_C test-engine
${TEST_ENGINE_SRC}
PACKAGES
geary-engine-internal
+ test-lib
${TEST_ENGINE_PACKAGES}
OPTIONS
${VALAC_OPTIONS}
@@ -127,6 +155,7 @@ vala_precompile(TEST_CLIENT_VALA_C test-client
PACKAGES
geary-client
geary-engine
+ test-lib
${TEST_ENGINE_PACKAGES}
${TEST_CLIENT_PACKAGES}
OPTIONS
@@ -135,8 +164,8 @@ OPTIONS
# Exclude from all so tests aren't built by default
add_executable(test-engine EXCLUDE_FROM_ALL ${TEST_ENGINE_VALA_C})
-target_link_libraries(test-engine ${DEPS_LIBRARIES} geary-engine)
+target_link_libraries(test-engine ${DEPS_LIBRARIES} geary-engine test-lib)
# Exclude from all so tests aren't built by default
add_executable(test-client EXCLUDE_FROM_ALL ${TEST_CLIENT_VALA_C} ${RESOURCES_C})
-target_link_libraries(test-client ${DEPS_LIBRARIES} geary-client geary-engine)
+target_link_libraries(test-client ${DEPS_LIBRARIES} geary-client geary-engine test-lib)
diff --git a/test/client/application/geary-configuration-test.vala
b/test/client/application/geary-configuration-test.vala
index fc8c18f..cd119cf 100644
--- a/test/client/application/geary-configuration-test.vala
+++ b/test/client/application/geary-configuration-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class ConfigurationTest : Gee.TestCase {
+class ConfigurationTest : TestCase {
private Configuration test_config = null;
diff --git a/test/client/components/client-web-view-test-case.vala
b/test/client/components/client-web-view-test-case.vala
index 2a26c22..5bbfb95 100644
--- a/test/client/components/client-web-view-test-case.vala
+++ b/test/client/components/client-web-view-test-case.vala
@@ -8,7 +8,7 @@
// Defined by CMake build script.
extern const string _BUILD_ROOT_DIR;
-public abstract class ClientWebViewTestCase<V> : Gee.TestCase {
+public abstract class ClientWebViewTestCase<V> : TestCase {
protected V? test_view = null;
protected Configuration? config = null;
diff --git a/test/client/components/client-web-view-test.vala
b/test/client/components/client-web-view-test.vala
index 7ad3f2d..218486f 100644
--- a/test/client/components/client-web-view-test.vala
+++ b/test/client/components/client-web-view-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-public class ClientWebViewTest : Gee.TestCase {
+public class ClientWebViewTest : TestCase {
public ClientWebViewTest() {
base("ClientWebViewTest");
diff --git a/test/engine/api/geary-account-test.vala b/test/engine/api/geary-account-mock.vala
similarity index 100%
rename from test/engine/api/geary-account-test.vala
rename to test/engine/api/geary-account-mock.vala
diff --git a/test/engine/api/geary-attachment-test.vala b/test/engine/api/geary-attachment-test.vala
index 983cdd8..0c3c919 100644
--- a/test/engine/api/geary-attachment-test.vala
+++ b/test/engine/api/geary-attachment-test.vala
@@ -8,7 +8,7 @@
// Defined by CMake build script.
extern const string _SOURCE_ROOT_DIR;
-class Geary.AttachmentTest : Gee.TestCase {
+class Geary.AttachmentTest : TestCase {
private const string ATTACHMENT_ID = "test-id";
private const string CONTENT_TYPE = "image/png";
diff --git a/test/engine/api/geary-email-identifier-test.vala
b/test/engine/api/geary-email-identifier-mock.vala
similarity index 100%
rename from test/engine/api/geary-email-identifier-test.vala
rename to test/engine/api/geary-email-identifier-mock.vala
diff --git a/test/engine/api/geary-email-properties-test.vala
b/test/engine/api/geary-email-properties-mock.vala
similarity index 100%
rename from test/engine/api/geary-email-properties-test.vala
rename to test/engine/api/geary-email-properties-mock.vala
diff --git a/test/engine/api/geary-engine-test.vala b/test/engine/api/geary-engine-test.vala
index c504dd2..de659ed 100644
--- a/test/engine/api/geary-engine-test.vala
+++ b/test/engine/api/geary-engine-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.EngineTest : Gee.TestCase {
+class Geary.EngineTest : TestCase {
private Engine? engine = null;
private File? tmp = null;
diff --git a/test/engine/api/geary-folder-test.vala b/test/engine/api/geary-folder-mock.vala
similarity index 100%
rename from test/engine/api/geary-folder-test.vala
rename to test/engine/api/geary-folder-mock.vala
diff --git a/test/engine/api/geary-folder-path-test.vala b/test/engine/api/geary-folder-path-mock.vala
similarity index 100%
rename from test/engine/api/geary-folder-path-test.vala
rename to test/engine/api/geary-folder-path-mock.vala
diff --git a/test/engine/app/app-conversation-set-test.vala b/test/engine/app/app-conversation-set-test.vala
index 51069e7..1bc3421 100644
--- a/test/engine/app/app-conversation-set-test.vala
+++ b/test/engine/app/app-conversation-set-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.App.ConversationSetTest : Gee.TestCase {
+class Geary.App.ConversationSetTest : TestCase {
ConversationSet? test = null;
diff --git a/test/engine/app/app-conversation-test.vala b/test/engine/app/app-conversation-test.vala
index 7a4eb2b..719c394 100644
--- a/test/engine/app/app-conversation-test.vala
+++ b/test/engine/app/app-conversation-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.App.ConversationTest : Gee.TestCase {
+class Geary.App.ConversationTest : TestCase {
Conversation? test = null;
diff --git a/test/engine/imap-engine/account-processor-test.vala
b/test/engine/imap-engine/account-processor-test.vala
index 44e7baf..70712b6 100644
--- a/test/engine/imap-engine/account-processor-test.vala
+++ b/test/engine/imap-engine/account-processor-test.vala
@@ -9,7 +9,7 @@ errordomain AccountProcessorTestError {
TEST;
}
-public class Geary.ImapEngine.AccountProcessorTest : Gee.TestCase {
+public class Geary.ImapEngine.AccountProcessorTest : TestCase {
public class TestOperation : AccountOperation {
diff --git a/test/engine/imap/command/imap-create-command-test.vala
b/test/engine/imap/command/imap-create-command-test.vala
index 9e3fe14..0c1f5db 100644
--- a/test/engine/imap/command/imap-create-command-test.vala
+++ b/test/engine/imap/command/imap-create-command-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.Imap.CreateCommandTest : Gee.TestCase {
+class Geary.Imap.CreateCommandTest : TestCase {
public CreateCommandTest() {
diff --git a/test/engine/imap/response/imap-namespace-response-test.vala
b/test/engine/imap/response/imap-namespace-response-test.vala
index c4fd432..d0ea776 100644
--- a/test/engine/imap/response/imap-namespace-response-test.vala
+++ b/test/engine/imap/response/imap-namespace-response-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.Imap.NamespaceResponseTest : Gee.TestCase {
+class Geary.Imap.NamespaceResponseTest : TestCase {
public NamespaceResponseTest() {
diff --git a/test/engine/imap/transport/imap-deserializer-test.vala
b/test/engine/imap/transport/imap-deserializer-test.vala
index 71b55ba..2ddeef2 100644
--- a/test/engine/imap/transport/imap-deserializer-test.vala
+++ b/test/engine/imap/transport/imap-deserializer-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.Imap.DeserializerTest : Gee.TestCase {
+class Geary.Imap.DeserializerTest : TestCase {
protected enum Expect { MESSAGE, EOS, DESER_FAIL; }
diff --git a/test/engine/mime-content-type-test.vala b/test/engine/mime-content-type-test.vala
index 4c4800b..b1bdd4d 100644
--- a/test/engine/mime-content-type-test.vala
+++ b/test/engine/mime-content-type-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.Mime.ContentTypeTest : Gee.TestCase {
+class Geary.Mime.ContentTypeTest : TestCase {
public ContentTypeTest() {
base("Geary.Mime.ContentTypeTest");
diff --git a/test/engine/rfc822-mailbox-address-test.vala b/test/engine/rfc822-mailbox-address-test.vala
index 1ab923c..2502cde 100644
--- a/test/engine/rfc822-mailbox-address-test.vala
+++ b/test/engine/rfc822-mailbox-address-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
+class Geary.RFC822.MailboxAddressTest : TestCase {
public MailboxAddressTest() {
base("Geary.RFC822.MailboxAddressTest");
diff --git a/test/engine/rfc822-mailbox-addresses-test.vala b/test/engine/rfc822-mailbox-addresses-test.vala
index 706d2d8..45853a0 100644
--- a/test/engine/rfc822-mailbox-addresses-test.vala
+++ b/test/engine/rfc822-mailbox-addresses-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.RFC822.MailboxAddressesTest : Gee.TestCase {
+class Geary.RFC822.MailboxAddressesTest : TestCase {
public MailboxAddressesTest() {
base("Geary.RFC822.MailboxAddressesTest");
diff --git a/test/engine/rfc822-message-data-test.vala b/test/engine/rfc822-message-data-test.vala
index 728f37f..156fe48 100644
--- a/test/engine/rfc822-message-data-test.vala
+++ b/test/engine/rfc822-message-data-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.RFC822.MessageDataTest : Gee.TestCase {
+class Geary.RFC822.MessageDataTest : TestCase {
public MessageDataTest() {
base("Geary.RFC822.MessageDataTest");
diff --git a/test/engine/rfc822-message-test.vala b/test/engine/rfc822-message-test.vala
index 4d5b6d4..aaca0c8 100644
--- a/test/engine/rfc822-message-test.vala
+++ b/test/engine/rfc822-message-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.RFC822.MessageTest : Gee.TestCase {
+class Geary.RFC822.MessageTest : TestCase {
public MessageTest() {
base("Geary.RFC822.MessageTest");
diff --git a/test/engine/rfc822-utils-test.vala b/test/engine/rfc822-utils-test.vala
index a94cc79..d478cb4 100644
--- a/test/engine/rfc822-utils-test.vala
+++ b/test/engine/rfc822-utils-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.RFC822.Utils.Test : Gee.TestCase {
+class Geary.RFC822.Utils.Test : TestCase {
public Test() {
base("Geary.RFC822.Utils.Test");
diff --git a/test/engine/util-html-test.vala b/test/engine/util-html-test.vala
index 87b7dec..4f3b112 100644
--- a/test/engine/util-html-test.vala
+++ b/test/engine/util-html-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.HTML.UtilTest : Gee.TestCase {
+class Geary.HTML.UtilTest : TestCase {
public UtilTest() {
base("Geary.HTML.Util");
diff --git a/test/engine/util-idle-manager-test.vala b/test/engine/util-idle-manager-test.vala
index 6a049d2..0d2b2ab 100644
--- a/test/engine/util-idle-manager-test.vala
+++ b/test/engine/util-idle-manager-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.IdleManagerTest : Gee.TestCase {
+class Geary.IdleManagerTest : TestCase {
public IdleManagerTest() {
base("Geary.IdleManagerTest");
diff --git a/test/engine/util-inet-test.vala b/test/engine/util-inet-test.vala
index 13acf68..a52d412 100644
--- a/test/engine/util-inet-test.vala
+++ b/test/engine/util-inet-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.Inet.Test : Gee.TestCase {
+class Geary.Inet.Test : TestCase {
public Test() {
base("Geary.Inet.Test");
diff --git a/test/engine/util-js-test.vala b/test/engine/util-js-test.vala
index 66e8388..fd63842 100644
--- a/test/engine/util-js-test.vala
+++ b/test/engine/util-js-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-public class Geary.JS.Test : Gee.TestCase {
+public class Geary.JS.Test : TestCase {
public Test() {
base("Geary.JS.Test");
diff --git a/test/engine/util-string-test.vala b/test/engine/util-string-test.vala
index cb4db93..29ecd4b 100644
--- a/test/engine/util-string-test.vala
+++ b/test/engine/util-string-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.String.Test : Gee.TestCase {
+class Geary.String.Test : TestCase {
public Test() {
base("Geary.String.Test");
diff --git a/test/engine/util-timeout-manager-test.vala b/test/engine/util-timeout-manager-test.vala
index 6a55ea0..1539082 100644
--- a/test/engine/util-timeout-manager-test.vala
+++ b/test/engine/util-timeout-manager-test.vala
@@ -5,7 +5,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-class Geary.TimeoutManagerTest : Gee.TestCase {
+class Geary.TimeoutManagerTest : TestCase {
// add_seconds seems to vary wildly, so needs a large epsilon
private const double SECONDS_EPSILON = 1.8;
diff --git a/test/meson.build b/test/meson.build
index 964fc54..86fde3c 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,14 +1,23 @@
+geary_test_lib_sources = [
+ 'test-case.vala',
+]
+
geary_test_engine_sources = [
'test-engine.vala',
- 'testcase.vala',
- 'engine/api/geary-account-test.vala',
+ # These should be included in the test lib sources, but we can't
+ # since that would make the test lib depend on geary-engine.vapi,
+ # and the engine test sute needs to depend
+ # geary-engine_internal.vapi, which leads to duplicate symbols when
+ # linking
+ 'engine/api/geary-account-mock.vala',
+ 'engine/api/geary-email-identifier-mock.vala',
+ 'engine/api/geary-email-properties-mock.vala',
+ 'engine/api/geary-folder-mock.vala',
+ 'engine/api/geary-folder-path-mock.vala',
+
'engine/api/geary-attachment-test.vala',
'engine/api/geary-engine-test.vala',
- 'engine/api/geary-email-identifier-test.vala',
- 'engine/api/geary-email-properties-test.vala',
- 'engine/api/geary-folder-test.vala',
- 'engine/api/geary-folder-path-test.vala',
'engine/app/app-conversation-test.vala',
'engine/app/app-conversation-set-test.vala',
'engine/imap/command/imap-create-command-test.vala',
@@ -31,7 +40,6 @@ geary_test_engine_sources = [
geary_test_client_sources = [
'test-client.vala',
- 'testcase.vala',
'client/application/geary-configuration-test.vala',
'client/components/client-web-view-test.vala',
@@ -46,30 +54,33 @@ geary_test_client_sources = [
geary_resources
]
-geary_test_engine_dependencies = [
- geary_engine_internal_dep,
+geary_test_lib_dependencies = [
gee,
gio,
- glib,
- gmime,
- javascriptcoregtk,
- libunwind,
- libxml,
- sqlite,
+ glib
+]
+
+geary_test_engine_dependencies = [
+ geary_engine_internal_dep
]
+geary_test_engine_dependencies += geary_engine_dependencies
geary_test_client_dependencies = [
- geary_client_dep,
- geary_engine_dep,
- gee,
- gmime,
- gtk,
- libsoup,
- webkit2gtk,
+ geary_client_dep
]
+geary_test_client_dependencies += geary_client_dependencies
+
+geary_test_lib = static_library('geary-test-lib',
+ geary_test_lib_sources,
+ dependencies: geary_test_lib_dependencies,
+ include_directories: config_h_dir,
+ vala_args: geary_vala_options,
+ c_args: geary_c_options,
+)
geary_test_engine_bin = executable('geary-test-engine',
geary_test_engine_sources,
+ link_with: geary_test_lib,
dependencies: geary_test_engine_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_options,
@@ -79,6 +90,7 @@ geary_test_engine_bin = executable('geary-test-engine',
geary_test_client_bin = executable('geary-test-client',
geary_test_client_sources,
dependencies: geary_test_client_dependencies,
+ link_with: geary_test_lib,
include_directories: config_h_dir,
vala_args: geary_vala_options,
c_args: geary_c_options,
diff --git a/test/testcase.vala b/test/test-case.vala
similarity index 78%
rename from test/testcase.vala
rename to test/test-case.vala
index 2fcde01..b17ce89 100644
--- a/test/testcase.vala
+++ b/test/test-case.vala
@@ -1,5 +1,4 @@
-/* testcase.vala
- *
+/*
* Copyright (C) 2009 Julien Peeters
* Copyright (C) 2017 Michael Gratton
*
@@ -22,7 +21,7 @@
* Michael Gratton <mike vee net>
*/
-public abstract class Gee.TestCase : Object {
+public abstract class TestCase : Object {
protected MainContext main_loop = MainContext.default();
@@ -32,18 +31,22 @@ public abstract class Gee.TestCase : Object {
public delegate void TestMethod() throws Error;
- public TestCase (string name) {
- this.suite = new GLib.TestSuite (name);
+ public TestCase(string name) {
+ this.suite = new GLib.TestSuite(name);
}
- public void add_test (string name, owned TestMethod test) {
- var adaptor = new Adaptor (name, (owned)test, this);
+ public void add_test(string name, owned TestMethod test) {
+ var adaptor = new Adaptor(name, (owned) test, this);
this.adaptors += adaptor;
- this.suite.add (new GLib.TestCase (adaptor.name,
- adaptor.set_up,
- adaptor.run,
- adaptor.tear_down ));
+ this.suite.add(
+ new GLib.TestCase(
+ adaptor.name,
+ adaptor.set_up,
+ adaptor.run,
+ adaptor.tear_down
+ )
+ );
}
public virtual void set_up() throws Error {
@@ -52,7 +55,7 @@ public abstract class Gee.TestCase : Object {
public virtual void tear_down() throws Error {
}
- public GLib.TestSuite get_suite () {
+ public GLib.TestSuite get_suite() {
return this.suite;
}
@@ -73,16 +76,16 @@ public abstract class Gee.TestCase : Object {
}
private class Adaptor {
- [CCode (notify = false)]
+
public string name { get; private set; }
private TestMethod test;
private TestCase test_case;
- public Adaptor (string name,
- owned TestMethod test,
- TestCase test_case) {
+ public Adaptor(string name,
+ owned TestMethod test,
+ TestCase test_case) {
this.name = name;
- this.test = (owned)test;
+ this.test = (owned) test;
this.test_case = test_case;
}
@@ -96,7 +99,7 @@ public abstract class Gee.TestCase : Object {
public void run(void* fixture) {
try {
- this.test ();
+ this.test();
} catch (Error err) {
assert_no_error(err);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]