ObjFW  Check-in [4682e8f902]

Overview
Comment:Migrate OFWindowsRegistryKeyTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 4682e8f90213c5497e887247392a4188abb869beb886495a4001963111347514
User & Date: js on 2024-02-17 21:04:33
Other Links: branch diff | manifest | tags
Context
2024-02-17
22:12
Migrate OFHTTPCookieTests to ObjFWTest check-in: 677b61582e user: js tags: objfwtest
21:04
Migrate OFWindowsRegistryKeyTests to ObjFWTest check-in: 4682e8f902 user: js tags: objfwtest
20:39
Fix OFStringTests on Windows check-in: cb8e4b80ad user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [ba61598ebe] to [020f00eed1].

48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81







+


















+







       OFXMLElementBuilderTests.m	\
       ${RUNTIME_ARC_TESTS_M}		\
       RuntimeTests.m			\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       ${USE_SRCS_WINDOWS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFDNSResolverTests.m	\
	       OFSocketTests.m		\
	       OFTCPSocketTests.m	\
	       OFUDPSocketTests.m	\
	       ${USE_SRCS_IPX}		\
	       ${USE_SRCS_UNIX_SOCKETS}	\
	       ${USE_SRCS_APPLETALK}
SRCS_APPLETALK = OFDDPSocketTests.m
SRCS_IPX = OFIPXSocketTests.m		\
	   OFSPXSocketTests.m		\
	   OFSPXStreamSocketTests.m
SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m	\
		    OFUNIXStreamSocketTests.m
SRCS_SUBPROCESSES = OFSubprocessTests.m
SRCS_THREADS = OFThreadTests.m
SRCS_WINDOWS = OFWindowsRegistryKeyTests.m

include ../buildsys.mk

testfile_bin.m: testfile.bin
	${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@
testfile_ini.m: testfile.ini
	${SHELL} ../utils/objfw-embed testfile.ini testfile.ini $@

Renamed and modified tests/OFWindowsRegistryKeyTests.m [0f0fbee00b] to new_tests/OFWindowsRegistryKeyTests.m [295a442df9].

11
12
13
14
15
16
17
18


19








































20
21
22
23
24
25































26

27









28
29
30
31
32

33
34
35

36
37
38

39
40
41
42
43
44

45
46
47

48
49
50


51
52
53
54
55
56
57




58
59
60
61
62
63
64
65
66
67
68

69
70
71
72

73
74

75
76
77
78
79
80
81
82


83
84
85
86


87
88
89
90
91
92
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60






61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102
103
104



105



106



107


108



109



110



111
112







113
114
115
116







117



118




119


120








121
122

123


124
125




126
127







-
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
-
+
+
+
+
+
+
+
+
+


-
-
-
+
-
-
-
+
-
-
-
+
-
-

-
-
-
+
-
-
-
+
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-

-
-
-
+
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
+
+
-

-
-
+
+
-
-
-
-


 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"
#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFWindowsRegistryKeyTests: OTTestCase
{
	OFWindowsRegistryKey *_softwareKey, *_objFWKey;
}
@end

@implementation OFWindowsRegistryKeyTests
- (void)setUp
{
	[super setUp];

	_softwareKey = [[[OFWindowsRegistryKey currentUserKey]
	    openSubkeyAtPath: @"Software"
		accessRights: KEY_ALL_ACCESS
		     options: 0] retain];
	_objFWKey = [[_softwareKey createSubkeyAtPath: @"ObjFW"
					 accessRights: KEY_ALL_ACCESS
				   securityAttributes: NULL
					      options: 0
					  disposition: NULL] retain];
}

- (void)tearDown
{
	[_softwareKey deleteSubkeyAtPath: @"ObjFW"];

	[super tearDown];
}

- (void)dealloc
{
	[_softwareKey release];
	[_objFWKey release];

	[super dealloc];
}

- (void)testClassesRootKey
{
	OTAssertEqual([[OFWindowsRegistryKey classesRootKey] class],
static OFString *const module = @"OFWindowsRegistryKey";

@implementation TestsAppDelegate (OFWindowsRegistryKeyTests)
- (void)windowsRegistryKeyTests
{
	void *pool = objc_autoreleasePoolPush();
	    [OFWindowsRegistryKey class]);
}

- (void)testCurrentConfigKey
{
	OTAssertEqual([[OFWindowsRegistryKey currentConfigKey] class],
	    [OFWindowsRegistryKey class]);
}

- (void)testCurrentUserKey
{
	OTAssertEqual([[OFWindowsRegistryKey currentUserKey] class],
	    [OFWindowsRegistryKey class]);
}

- (void)testLocalMachineKey
{
	OTAssertEqual([[OFWindowsRegistryKey localMachineKey] class],
	    [OFWindowsRegistryKey class]);
}

- (void)testOpenSubkeyAtPathAccessRightsOptionsThrowsForNonExistentKey
{
	OTAssertThrowsSpecific([[OFWindowsRegistryKey currentUserKey]
	    openSubkeyAtPath: @"nonexistent"
		accessRights: KEY_ALL_ACCESS
		     options: 0], OFOpenWindowsRegistryKeyFailedException);
}

- (void)testSetAndGetData
{
	OFData *data = [OFData dataWithItems: "abcdef" count: 6];
	DWORD type;
	OFWindowsRegistryKey *softwareKey, *objFWKey;

	[_objFWKey setData: data forValueNamed: @"data" type: REG_BINARY];
	OTAssertEqualObjects([_objFWKey dataForValueNamed: @"data" type: &type],
	    data);
	OTAssertEqual(type, REG_BINARY);
}

- (void)testSetAndGetString
{
	DWORD type;

	TEST(@"+[OFWindowsRegistryKey classesRootKey]",
	    [OFWindowsRegistryKey classesRootKey])

	[_objFWKey setString: @"foobar" forValueNamed: @"string"];
	TEST(@"+[OFWindowsRegistryKey currentConfigKey]",
	    [OFWindowsRegistryKey currentConfigKey])

	OTAssertEqualObjects([_objFWKey stringForValueNamed: @"string"],
	TEST(@"+[OFWindowsRegistryKey currentUserKey]",
	    [OFWindowsRegistryKey currentUserKey])

	    @"foobar");
	TEST(@"+[OFWindowsRegistryKey localMachineKey]",
	    [OFWindowsRegistryKey localMachineKey])

	TEST(@"+[OFWindowsRegistryKey usersKey]",
	    [OFWindowsRegistryKey usersKey])

	[_objFWKey setString: @"%PATH%;foo"
	    TEST(@"-[openSubkeyAtPath:accessRights:options:] #1",
	    (softwareKey = [[OFWindowsRegistryKey currentUserKey]
		openSubkeyAtPath: @"Software"
	       forValueNamed: @"expand"
		    accessRights: KEY_ALL_ACCESS
			 options: 0]))

			type: REG_EXPAND_SZ];
	OTAssertEqualObjects([_objFWKey stringForValueNamed: @"expand"
	EXPECT_EXCEPTION(@"-[openSubkeyAtPath:accessRights:options:] #2",
	    OFOpenWindowsRegistryKeyFailedException,
	    [[OFWindowsRegistryKey currentUserKey]
		openSubkeyAtPath: @"nonexistent"
		    accessRights: KEY_ALL_ACCESS
			 options: 0])

						       type: &type],
	    @"%PATH%;foo");
	OTAssertEqual(type, REG_EXPAND_SZ);
}
	TEST(@"-[createSubkeyAtPath:accessRights:securityAttributes:options:"
	    @"disposition:]",
	    (objFWKey = [softwareKey createSubkeyAtPath: @"ObjFW"
					   accessRights: KEY_ALL_ACCESS
				     securityAttributes: NULL
						options: 0
					    disposition: NULL]))

	TEST(@"-[setData:forValueNamed:type:]",
	    R([objFWKey setData: data forValueNamed: @"data" type: REG_BINARY]))

- (void)testDeleteValue
	TEST(@"-[dataForValueNamed:subkeyPath:flags:type:]",
	    [[objFWKey dataForValueNamed: @"data" type: &type] isEqual: data] &&
	    type == REG_BINARY)

{
	TEST(@"-[setString:forValueNamed:type:]",
	    R([objFWKey setString: @"foobar" forValueNamed: @"string"]) &&
	[_objFWKey setString: @"foobar" forValueNamed: @"deleteme"];
	    R([objFWKey setString: @"%PATH%;foo"
		    forValueNamed: @"expand"
			     type: REG_EXPAND_SZ]))

	TEST(@"-[stringForValue:subkeyPath:]",
	    [[objFWKey stringForValueNamed: @"string"] isEqual: @"foobar"] &&
	    [[objFWKey stringForValueNamed: @"expand" type: &type]
	    isEqual: @"%PATH%;foo"] &&
	OTAssertEqualObjects([_objFWKey stringForValueNamed: @"deleteme"],
	    @"foobar");
	    type == REG_EXPAND_SZ)

	TEST(@"-[deleteValueNamed:]", R([objFWKey deleteValueNamed: @"data"]))

	[_objFWKey deleteValueNamed: @"deleteme"];
	OTAssertNil([_objFWKey stringForValueNamed: @"deleteme"]);
	TEST(@"-[deleteSubkeyAtPath:]",
	    R([softwareKey deleteSubkeyAtPath: @"ObjFW"]))

	objc_autoreleasePoolPop(pool);
}
@end

Modified tests/Makefile from [6326adde66] to [45af6145a4].

19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
19
20
21
22
23
24
25

26

27
28
29
30

31
32
33
34
35
36
37







-
+
-




-







       OFMemoryStreamTests.m		\
       OFStreamTests.m			\
       OFValueTests.m			\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SOCKETS}
       ${USE_SRCS_WINDOWS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m
SRCS_WINDOWS = OFWindowsRegistryKeyTests.m

IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test

include ../buildsys.mk

.PHONY: run run-on-ios run-on-android

Modified tests/TestsAppDelegate.h from [016922afeb] to [dba04c9406].

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
95
96
97
98
99
100
101




102
103
104
105
106
107
108
109







-
-
-
-








- (void)streamTests;
@end

@interface TestsAppDelegate (OFValueTests)
- (void)valueTests;
@end

@interface TestsAppDelegate (OFWindowsRegistryKeyTests)
- (void)windowsRegistryKeyTests;
@end

@interface TestsAppDelegate (OFXMLNodeTests)
- (void)XMLNodeTests;
@end

@interface TestsAppDelegate (OFXMLParserTests)
    <OFXMLParserDelegate, OFXMLElementBuilderDelegate>
- (void)XMLParserTests;
@end

Modified tests/TestsAppDelegate.m from [5c2ea3ac4e] to [fa7d26d865].

385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
385
386
387
388
389
390
391




392
393
394
395
396
397
398







-
-
-
-







#ifdef OF_HAVE_SOCKETS
	[self HTTPCookieTests];
	[self HTTPCookieManagerTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];

#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif

	[OFStdOut reset];

#if defined(OF_IOS)
	[OFStdOut writeFormat: @"%d tests failed!", _fails];
	[OFApplication terminateWithStatus: _fails];
#elif defined(OF_WII)
	[OFStdOut writeString: @"Press home button to exit!"];