1// AppFileInfoTest.cpp
2
3#include <stdio.h>
4#include <string>
5#include <unistd.h>
6
7#include <AppFileInfo.h>
8#include <Application.h>
9#include <Bitmap.h>
10#include <Directory.h>
11#include <Entry.h>
12#include <File.h>
13#include <fs_attr.h>
14#include <Path.h>
15#include <Resources.h>
16#include <Roster.h>
17#include <String.h>
18#include <TypeConstants.h>
19
20#include <cppunit/Test.h>
21#include <cppunit/TestCaller.h>
22#include <cppunit/TestSuite.h>
23#include <TestShell.h>
24#include <TestUtils.h>
25#include <cppunit/TestAssert.h>
26
27#include "AppFileInfoTest.h"
28#include "../app/bmessenger/Helpers.h"
29
30// test dirs/files/types
31static const char *testDir			= "/tmp/testDir";
32static const char *testFile1		= "/tmp/testDir/file1";
33static const char *testFile2		= "/tmp/testDir/file2";
34static const char *testFile3		= "/tmp/testDir/file3";
35static const char *testFile4		= "/tmp/testDir/file4";
36static const char *testType1
37	= "application/x-vnd.obos.app-file-info-test1";
38static const char *testType2
39	= "application/x-vnd.obos.app-file-info-test2";
40static const char *testType3
41	= "application/x-vnd.obos.app-file-info-test3";
42static const char *testType4
43	= "application/x-vnd.obos.app-file-info-test4";
44static const char *invalidTestType	= "invalid/mime/type";
45static const char *tooLongTestType	=
46"0123456789012345678901234567890123456789012345678901234567890123456789"
47"0123456789012345678901234567890123456789012345678901234567890123456789"
48"0123456789012345678901234567890123456789012345678901234567890123456789"
49"0123456789012345678901234567890123456789012345678901234567890123456789"
50;
51static const char *testAppSignature1
52	= "application/x-vnd.obos.app-file-info-test-app1";
53static const char *testAppSignature2
54	= "application/x-vnd.obos.app-file-info-test-app2";
55static const char *testAppSignature3
56	= "application/x-vnd.obos.app-file-info-test-app3";
57
58
59// attributes
60static const char *kTypeAttribute				= "BEOS:TYPE";
61static const char *kSignatureAttribute			= "BEOS:APP_SIG";
62static const char *kAppFlagsAttribute			= "BEOS:APP_FLAGS";
63static const char *kSupportedTypesAttribute		= "BEOS:FILE_TYPES";
64static const char *kMiniIconAttribute			= "BEOS:M:STD_ICON";
65static const char *kLargeIconAttribute			= "BEOS:L:STD_ICON";
66static const char *kVersionInfoAttribute		= "BEOS:APP_VERSION";
67static const char *kMiniIconForTypeAttribute	= "BEOS:M:";
68static const char *kLargeIconForTypeAttribute	= "BEOS:L:";
69
70// resource IDs
71static const int32 kTypeResourceID				= 2;
72static const int32 kSignatureResourceID			= 1;
73static const int32 kAppFlagsResourceID			= 1;
74static const int32 kSupportedTypesResourceID	= 1;
75static const int32 kMiniIconResourceID			= 101;
76static const int32 kLargeIconResourceID			= 101;
77static const int32 kVersionInfoResourceID		= 1;
78static const int32 kMiniIconForTypeResourceID	= 0;
79static const int32 kLargeIconForTypeResourceID	= 0;
80
81
82enum {
83	APP_FLAGS_TYPE				= 'APPF',
84	MINI_ICON_TYPE				= 'MICN',
85	LARGE_ICON_TYPE				= 'ICON',
86	VERSION_INFO_TYPE			= 'APPV',
87};
88
89// create_test_icon
90static
91BBitmap *
92create_test_icon(icon_size size, int fill)
93{
94	BBitmap *icon = NULL;
95	// create
96	switch (size) {
97		case B_MINI_ICON:
98			icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
99			break;
100		case B_LARGE_ICON:
101			icon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
102			break;
103	}
104	// fill
105	if (icon)
106		memset(icon->Bits(), fill, icon->BitsLength());
107	return icon;
108}
109
110// icon_equal
111static
112bool
113icon_equal(const BBitmap *icon1, const BBitmap *icon2)
114{
115	return (icon1->Bounds() == icon2->Bounds()
116			&& icon1->BitsLength() == icon2->BitsLength()
117			&& memcmp(icon1->Bits(), icon2->Bits(), icon1->BitsLength()) == 0);
118}
119
120// == (version_info)
121static
122bool
123operator==(const version_info &info1, const version_info &info2)
124{
125	return (info1.major == info2.major
126			&& info1.middle == info2.middle
127			&& info1.minor == info2.minor
128			&& info1.variety == info2.variety
129			&& info1.internal == info2.internal
130			&& !strcmp(info1.short_info, info2.short_info)
131			&& !strcmp(info1.long_info, info2.long_info));
132}
133
134
135// Suite
136CppUnit::Test*
137AppFileInfoTest::Suite() {
138	CppUnit::TestSuite *suite = new CppUnit::TestSuite();
139	typedef CppUnit::TestCaller<AppFileInfoTest> TC;
140
141	suite->addTest( new TC("BAppFileInfo::Init Test1",
142						   &AppFileInfoTest::InitTest1) );
143	suite->addTest( new TC("BAppFileInfo::Init Test2",
144						   &AppFileInfoTest::InitTest2) );
145	suite->addTest( new TC("BAppFileInfo::Type Test",
146						   &AppFileInfoTest::TypeTest) );
147	suite->addTest( new TC("BAppFileInfo::Signature Test",
148						   &AppFileInfoTest::SignatureTest) );
149	suite->addTest( new TC("BAppFileInfo::App Flags Test",
150						   &AppFileInfoTest::AppFlagsTest) );
151	suite->addTest( new TC("BAppFileInfo::Supported Types Test",
152						   &AppFileInfoTest::SupportedTypesTest) );
153	suite->addTest( new TC("BAppFileInfo::Icon Test",
154						   &AppFileInfoTest::IconTest) );
155	suite->addTest( new TC("BAppFileInfo::Version Info Test",
156						   &AppFileInfoTest::VersionInfoTest) );
157	suite->addTest( new TC("BAppFileInfo::Icon For Type Test",
158						   &AppFileInfoTest::IconForTypeTest) );
159	suite->addTest( new TC("BAppFileInfo::Info Location Test",
160						   &AppFileInfoTest::InfoLocationTest) );
161
162	return suite;
163}
164
165// setUp
166void
167AppFileInfoTest::setUp()
168{
169	BasicTest::setUp();
170	// create test dir and files
171	execCommand(
172		string("mkdir ") + testDir
173		+ "; touch " + testFile1
174			   + " " + testFile2
175			   + " " + testFile3
176			   + " " + testFile4
177	);
178	// create app
179	fApplication
180		= new BApplication("application/x-vnd.obos.app-file-info-test");
181	// create icons
182	fIconM1 = create_test_icon(B_MINI_ICON, 1);
183	fIconM2 = create_test_icon(B_MINI_ICON, 2);
184	fIconM3 = create_test_icon(B_MINI_ICON, 3);
185	fIconM4 = create_test_icon(B_MINI_ICON, 4);
186	fIconL1 = create_test_icon(B_LARGE_ICON, 1);
187	fIconL2 = create_test_icon(B_LARGE_ICON, 2);
188	fIconL3 = create_test_icon(B_LARGE_ICON, 3);
189	fIconL4 = create_test_icon(B_LARGE_ICON, 4);
190}
191
192// tearDown
193void
194AppFileInfoTest::tearDown()
195{
196	// delete the icons
197	delete fIconM1;
198	delete fIconM2;
199	delete fIconM3;
200	delete fIconM4;
201	delete fIconL1;
202	delete fIconL2;
203	delete fIconL3;
204	delete fIconL4;
205	fIconM1 = fIconM2 = fIconL1 = fIconL2 = NULL;
206	// delete the application
207	delete fApplication;
208	fApplication = NULL;
209	// remove the types we've added
210	const char * const testTypes[] = {
211		testType1, testType2, testType3, testType4,
212		testAppSignature1, testAppSignature2, testAppSignature3
213	};
214	for (uint32 i = 0; i < sizeof(testTypes) / sizeof(const char*); i++) {
215		BMimeType type(testTypes[i]);
216		type.Delete();
217	}
218
219	// delete the test dir
220	execCommand(string("rm -rf ") + testDir);
221
222	BasicTest::tearDown();
223}
224
225// SyncResources
226static
227void
228SyncResources(BAppFileInfo &info)
229{
230	struct node_info_hack {
231		virtual ~node_info_hack() {}
232		BNode		*fNode;
233		uint32		_reserved[2];
234		status_t	fCStatus;
235	};
236	struct app_file_info_hack : node_info_hack {
237		virtual ~app_file_info_hack() {}
238		BResources		*fResources;
239		info_location	fWhere;
240		uint32			_reserved[2];
241	};
242	app_file_info_hack &hackedInfo
243		= reinterpret_cast<app_file_info_hack&>(info);
244	BResources *resources = hackedInfo.fResources;
245	if (resources)
246		resources->Sync();
247}
248
249// ReadAttr
250static
251char*
252ReadAttr(BNode &node, const char *name, type_code type, size_t &size)
253{
254	attr_info info;
255	CHK(node.GetAttrInfo(name, &info) == B_OK);
256	CHK(info.type == type);
257	char *buffer = new char[info.size];
258	if (node.ReadAttr(name, type, 0, buffer, info.size) == info.size)
259		size = info.size;
260	else {
261		delete[] buffer;
262		CHK(false);
263	}
264	return buffer;
265}
266
267// ReadResource
268static
269char*
270ReadResource(BFile &file, const char *name, int32 id, type_code type,
271			 size_t &size)
272{
273	BResources resources;
274	CHK(resources.SetTo(&file) == B_OK);
275	int32 idFound;
276	CHK(resources.GetResourceInfo(type, name, &idFound, &size) == true);
277	CHK(idFound == id);
278	const void *resourceData = resources.LoadResource(type, name, &size);
279	CHK(resourceData != NULL);
280	char *buffer = new char[size];
281	memcpy(buffer, resourceData, size);
282	return buffer;
283}
284
285// CheckAttr
286static
287void
288CheckAttr(BNode &node, const char *name, type_code type, const void *data,
289		  int32 dataSize)
290{
291	attr_info info;
292	CHK(node.GetAttrInfo(name, &info) == B_OK);
293	CHK(info.type == type);
294	CHK(info.size == dataSize);
295	char *buffer = new char[dataSize];
296	AutoDeleter<char> deleter(buffer, true);
297	CHK(node.ReadAttr(name, type, 0, buffer, dataSize) == dataSize);
298	CHK(memcmp(buffer, data, dataSize) == 0);
299}
300
301// CheckResource
302static
303void
304CheckResource(BFile &file, const char *name, int32 id, type_code type,
305			  const void *data, size_t dataSize)
306{
307	BResources resources;
308	CHK(resources.SetTo(&file) == B_OK);
309	int32 idFound;
310	size_t size;
311	CHK(resources.GetResourceInfo(type, name, &idFound, &size) == true);
312	CHK(idFound == id);
313	CHK(size == dataSize);
314	const void *resourceData = resources.LoadResource(type, name, &size);
315	CHK(resourceData != NULL);
316	CHK(size == dataSize);
317	CHK(memcmp(resourceData, data, dataSize) == 0);
318}
319
320// CheckNoAttr
321static
322void
323CheckNoAttr(BNode &node, const char *name)
324{
325	attr_info info;
326	CHK(node.GetAttrInfo(name, &info) == B_ENTRY_NOT_FOUND);
327}
328
329// CheckNoResource
330static
331void
332CheckNoResource(BFile &file, const char *name)
333{
334	BResources resources;
335	CHK(resources.SetTo(&file) == B_OK);
336	type_code typeFound;
337	int32 idFound;
338	const char *nameFound;
339	size_t size;
340	bool found = false;
341	for (int32 i = 0;
342		 !found && resources.GetResourceInfo(i, &typeFound, &idFound,
343											 &nameFound, &size);
344		 i++) {
345		found = !strcmp(nameFound, name);
346	}
347	CHK(!found);
348}
349
350// TypeValue
351struct TypeValue
352{
353	TypeValue() : type() {}
354	TypeValue(const char *type) : type(type) {}
355
356	bool operator==(const TypeValue &value)
357	{
358		return (type == value.type);
359	}
360
361	string type;
362};
363
364// TypeSetter
365struct TypeSetter
366{
367	static status_t Set(BAppFileInfo &info, const TypeValue &value)
368	{
369		return info.SetType(value.type.c_str());
370	}
371};
372
373// TypeGetter
374struct TypeGetter
375{
376	static status_t Get(BAppFileInfo &info, TypeValue &value)
377	{
378		char buffer[B_MIME_TYPE_LENGTH];
379		status_t error = info.GetType(buffer);
380		if (error == B_OK)
381			value.type = buffer;
382		return error;
383	}
384};
385
386// TypeChecker
387struct TypeChecker
388{
389	static void CheckAttribute(BNode &file, const TypeValue &value)
390	{
391		CheckAttr(file, kTypeAttribute, B_MIME_STRING_TYPE, value.type.c_str(),
392				  value.type.length() + 1);
393	}
394
395	static void CheckResource(BFile &file, const TypeValue &value)
396	{
397		::CheckResource(file, kTypeAttribute, kTypeResourceID,
398						B_MIME_STRING_TYPE, value.type.c_str(),
399						value.type.length() + 1);
400	}
401};
402
403typedef TypeValue SignatureValue;
404
405// SignatureSetter
406struct SignatureSetter
407{
408	static status_t Set(BAppFileInfo &info, const SignatureValue &value)
409	{
410		return info.SetSignature(value.type.c_str());
411	}
412};
413
414// SignatureGetter
415struct SignatureGetter
416{
417	static status_t Get(BAppFileInfo &info, SignatureValue &value)
418	{
419		char buffer[B_MIME_TYPE_LENGTH];
420		status_t error = info.GetSignature(buffer);
421		if (error == B_OK)
422			value.type = buffer;
423		return error;
424	}
425};
426
427// SignatureChecker
428struct SignatureChecker
429{
430	static void CheckAttribute(BNode &file, const SignatureValue &value)
431	{
432		CheckAttr(file, kSignatureAttribute, B_MIME_STRING_TYPE, value.type.c_str(),
433				  value.type.length() + 1);
434	}
435
436	static void CheckResource(BFile &file, const SignatureValue &value)
437	{
438		::CheckResource(file, kSignatureAttribute, kSignatureResourceID,
439						B_MIME_STRING_TYPE, value.type.c_str(),
440						value.type.length() + 1);
441	}
442};
443
444// AppFlagsValue
445struct AppFlagsValue
446{
447	AppFlagsValue() : flags() {}
448	AppFlagsValue(uint32 flags) : flags(flags) {}
449
450	bool operator==(const AppFlagsValue &value)
451	{
452		return (flags == value.flags);
453	}
454
455	uint32 flags;
456};
457
458// AppFlagsSetter
459struct AppFlagsSetter
460{
461	static status_t Set(BAppFileInfo &info, const AppFlagsValue &value)
462	{
463		return info.SetAppFlags(value.flags);
464	}
465};
466
467// AppFlagsGetter
468struct AppFlagsGetter
469{
470	static status_t Get(BAppFileInfo &info, AppFlagsValue &value)
471	{
472		return info.GetAppFlags(&value.flags);
473	}
474};
475
476// AppFlagsChecker
477struct AppFlagsChecker
478{
479	static void CheckAttribute(BNode &file, const AppFlagsValue &value)
480	{
481		CheckAttr(file, kAppFlagsAttribute, APP_FLAGS_TYPE, &value.flags,
482				  sizeof(value.flags));
483	}
484
485	static void CheckResource(BFile &file, const AppFlagsValue &value)
486	{
487		::CheckResource(file, kAppFlagsAttribute, kAppFlagsResourceID,
488						APP_FLAGS_TYPE, &value.flags, sizeof(value.flags));
489	}
490};
491
492// SupportedTypesValue
493struct SupportedTypesValue
494{
495	SupportedTypesValue() : types() {}
496	SupportedTypesValue(const BMessage &types) : types(types) {}
497	SupportedTypesValue(const char **types, int32 count)
498		: types()
499	{
500		for (int32 i = 0; i < count; i++)
501			this->types.AddString("types", types[i]);
502	}
503
504	bool operator==(const SupportedTypesValue &value)
505	{
506		type_code type1, type2;
507		int32 count1, count2;
508		bool equal = (types.GetInfo("types", &type1, &count1) == B_OK
509					  && value.types.GetInfo("types", &type2, &count2) == B_OK
510					  && type1 == type2 && count1 == count2);
511
512		for (int32 i = 0; equal && i < count1; i++) {
513			BString str1, str2;
514			equal = types.FindString("types", i, &str1) == B_OK
515					&& value.types.FindString("types", i, &str2) == B_OK
516					&& str1 == str2;
517		}
518		return equal;
519	}
520
521	BMessage types;
522};
523
524// SupportedTypesSetter
525struct SupportedTypesSetter
526{
527	static status_t Set(BAppFileInfo &info, const SupportedTypesValue &value)
528	{
529		return info.SetSupportedTypes(&value.types, false);
530	}
531};
532
533// SupportedTypesGetter
534struct SupportedTypesGetter
535{
536	static status_t Get(BAppFileInfo &info, SupportedTypesValue &value)
537	{
538		return info.GetSupportedTypes(&value.types);
539	}
540};
541
542// SupportedTypesChecker
543struct SupportedTypesChecker
544{
545	static void CheckAttribute(BNode &file, const SupportedTypesValue &value)
546	{
547		size_t size;
548		char *buffer = ReadAttr(file, kSupportedTypesAttribute,
549								B_MESSAGE_TYPE, size);
550		AutoDeleter<char> deleter(buffer, true);
551		BMessage storedTypes;
552		CHK(storedTypes.Unflatten(buffer) == B_OK);
553		SupportedTypesValue storedValue(storedTypes);
554		CHK(storedValue == value);
555	}
556
557	static void CheckResource(BFile &file, const SupportedTypesValue &value)
558	{
559		size_t size;
560		char *buffer = ReadResource(file, kSupportedTypesAttribute,
561									kSupportedTypesResourceID, B_MESSAGE_TYPE,
562									size);
563		AutoDeleter<char> deleter(buffer, true);
564		BMessage storedTypes;
565		CHK(storedTypes.Unflatten(buffer) == B_OK);
566		SupportedTypesValue storedValue(storedTypes);
567		CHK(storedValue == value);
568	}
569};
570
571// IconValue
572struct IconValue
573{
574	IconValue() : mini(BRect(0, 0, 15, 15), B_CMAP8),
575				  large(BRect(0, 0, 31, 31), B_CMAP8) {}
576	IconValue(const BBitmap *mini, const BBitmap *large)
577		: mini(BRect(0, 0, 15, 15), B_CMAP8),
578		  large(BRect(0, 0, 31, 31), B_CMAP8)
579	{
580		this->mini.SetBits(mini->Bits(), mini->BitsLength(), 0,
581						   mini->ColorSpace());
582		this->large.SetBits(large->Bits(), large->BitsLength(), 0,
583							large->ColorSpace());
584	}
585
586	bool operator==(const IconValue &value)
587	{
588		return (icon_equal(&mini, &value.mini)
589				&& icon_equal(&large, &value.large));
590	}
591
592	BBitmap mini;
593	BBitmap large;
594};
595
596// IconSetter
597struct IconSetter
598{
599	static status_t Set(BAppFileInfo &info, const IconValue &value)
600	{
601		status_t error = info.SetIcon(&value.mini, B_MINI_ICON);
602		if (error == B_OK)
603			error = info.SetIcon(&value.large, B_LARGE_ICON);
604		return error;
605	}
606};
607
608// IconGetter
609struct IconGetter
610{
611	static status_t Get(BAppFileInfo &info, IconValue &value)
612	{
613		status_t error = info.GetIcon(&value.mini, B_MINI_ICON);
614		if (error == B_OK)
615			error = info.GetIcon(&value.large, B_LARGE_ICON);
616		return error;
617	}
618};
619
620// IconChecker
621struct IconChecker
622{
623	static void CheckAttribute(BNode &file, const IconValue &value)
624	{
625		CheckAttr(file, kMiniIconAttribute, MINI_ICON_TYPE, value.mini.Bits(),
626				  value.mini.BitsLength());
627		CheckAttr(file, kLargeIconAttribute, LARGE_ICON_TYPE,
628				  value.large.Bits(), value.large.BitsLength());
629	}
630
631	static void CheckResource(BFile &file, const IconValue &value)
632	{
633		::CheckResource(file, kMiniIconAttribute, kMiniIconResourceID,
634						MINI_ICON_TYPE, value.mini.Bits(),
635						value.mini.BitsLength());
636		::CheckResource(file, kLargeIconAttribute, kLargeIconResourceID,
637						LARGE_ICON_TYPE, value.large.Bits(),
638						value.large.BitsLength());
639	}
640};
641
642// VersionInfoValue
643struct VersionInfoValue
644{
645	VersionInfoValue() : app(), system() {}
646	VersionInfoValue(const version_info &app, const version_info &system)
647		: app(app), system(system) {}
648
649	bool operator==(const VersionInfoValue &value)
650	{
651		return (app == value.app && system == value.system);
652	}
653
654	version_info app;
655	version_info system;
656};
657
658// VersionInfoSetter
659struct VersionInfoSetter
660{
661	static status_t Set(BAppFileInfo &info, const VersionInfoValue &value)
662	{
663		status_t error = info.SetVersionInfo(&value.app, B_APP_VERSION_KIND);
664		if (error == B_OK)
665			error = info.SetVersionInfo(&value.system, B_SYSTEM_VERSION_KIND);
666		return error;
667	}
668};
669
670// VersionInfoGetter
671struct VersionInfoGetter
672{
673	static status_t Get(BAppFileInfo &info, VersionInfoValue &value)
674	{
675		status_t error = info.GetVersionInfo(&value.app, B_APP_VERSION_KIND);
676		if (error == B_OK)
677			error = info.GetVersionInfo(&value.system, B_SYSTEM_VERSION_KIND);
678		return error;
679	}
680};
681
682// VersionInfoChecker
683struct VersionInfoChecker
684{
685	static void CheckAttribute(BNode &file, const VersionInfoValue &value)
686	{
687		version_info infos[] = { value.app, value.system };
688		CheckAttr(file, kVersionInfoAttribute, VERSION_INFO_TYPE,
689				  infos, sizeof(infos));
690	}
691
692	static void CheckResource(BFile &file, const VersionInfoValue &value)
693	{
694		version_info infos[] = { value.app, value.system };
695		::CheckResource(file, kVersionInfoAttribute,
696						kVersionInfoResourceID, VERSION_INFO_TYPE,
697						infos, sizeof(infos));
698	}
699};
700
701// IconForTypeValue
702struct IconForTypeValue : public IconValue
703{
704//	IconForTypeValue() : type() {}
705//	IconForTypeValue(const BBitmap *mini, const BBitmap *large,
706//					 const char *type) : IconValue(mini, large), type(type) {}
707	IconForTypeValue() : type(testType1) {}
708	IconForTypeValue(const BBitmap *mini, const BBitmap *large)
709		: IconValue(mini, large), type(testType1) {}
710
711	string	type;
712};
713
714// IconForTypeSetter
715struct IconForTypeSetter
716{
717	static status_t Set(BAppFileInfo &info, const IconForTypeValue &value)
718	{
719		status_t error = info.SetIconForType(value.type.c_str(), &value.mini,
720											 B_MINI_ICON);
721		if (error == B_OK) {
722			error = info.SetIconForType(value.type.c_str(), &value.large,
723										B_LARGE_ICON);
724		}
725		return error;
726	}
727};
728
729// IconForTypeGetter
730struct IconForTypeGetter
731{
732	static status_t Get(BAppFileInfo &info, IconForTypeValue &value)
733	{
734		status_t error = info.GetIconForType(value.type.c_str(), &value.mini,
735											 B_MINI_ICON);
736		if (error == B_OK) {
737			error = info.GetIconForType(value.type.c_str(), &value.large,
738										B_LARGE_ICON);
739		}
740		return error;
741	}
742};
743
744// IconForTypeChecker
745struct IconForTypeChecker
746{
747	static void CheckAttribute(BNode &file, const IconForTypeValue &value)
748	{
749		string attrNameM(kMiniIconForTypeAttribute);
750		attrNameM += value.type;
751		CheckAttr(file, attrNameM.c_str(), MINI_ICON_TYPE, value.mini.Bits(),
752				  value.mini.BitsLength());
753		string attrNameL(kLargeIconForTypeAttribute);
754		attrNameL += value.type;
755		CheckAttr(file, attrNameL.c_str(), LARGE_ICON_TYPE,
756				  value.large.Bits(), value.large.BitsLength());
757	}
758
759	static void CheckResource(BFile &file, const IconForTypeValue &value)
760	{
761		string attrNameM(kMiniIconForTypeAttribute);
762		attrNameM += value.type;
763		::CheckResource(file, attrNameM.c_str(), kMiniIconForTypeResourceID,
764						MINI_ICON_TYPE, value.mini.Bits(),
765						value.mini.BitsLength());
766		string attrNameL(kLargeIconForTypeAttribute);
767		attrNameL += value.type;
768		::CheckResource(file, attrNameL.c_str(), kLargeIconForTypeResourceID,
769						LARGE_ICON_TYPE, value.large.Bits(),
770						value.large.BitsLength());
771	}
772};
773
774
775// CheckTypeAttr
776static
777void
778CheckTypeAttr(BNode &node, const char *data)
779{
780	CheckAttr(node, kTypeAttribute, B_MIME_STRING_TYPE, data,
781			  strlen(data) + 1);
782}
783
784// CheckTypeResource
785static
786void
787CheckTypeResource(BFile &file, const char *data)
788{
789	CheckResource(file, kTypeAttribute, kTypeResourceID, B_MIME_STRING_TYPE,
790				  data, strlen(data) + 1);
791}
792
793// CheckSignatureAttr
794static
795void
796CheckSignatureAttr(BNode &node, const char *data)
797{
798	CheckAttr(node, kSignatureAttribute, B_MIME_STRING_TYPE, data,
799			  strlen(data) + 1);
800}
801
802// CheckSignatureResource
803static
804void
805CheckSignatureResource(BFile &file, const char *data)
806{
807	CheckResource(file, kSignatureAttribute, kSignatureResourceID,
808				  B_MIME_STRING_TYPE, data, strlen(data) + 1);
809}
810
811// CheckAppFlagsAttr
812static
813void
814CheckAppFlagsAttr(BNode &node, uint32 flags)
815{
816	CheckAttr(node, kAppFlagsAttribute, APP_FLAGS_TYPE, &flags, sizeof(flags));
817}
818
819// CheckAppFlagsResource
820static
821void
822CheckAppFlagsResource(BFile &file, uint32 flags)
823{
824	CheckResource(file, kAppFlagsAttribute, kAppFlagsResourceID,
825				  APP_FLAGS_TYPE, &flags, sizeof(flags));
826}
827
828// CheckSupportedTypesAttr
829static
830void
831CheckSupportedTypesAttr(BNode &node, const BMessage *data)
832{
833	SupportedTypesChecker::CheckAttribute(node, SupportedTypesValue(*data));
834}
835
836// CheckSupportedTypesResource
837static
838void
839CheckSupportedTypesResource(BFile &file, const BMessage *data)
840{
841	SupportedTypesChecker::CheckResource(file, SupportedTypesValue(*data));
842}
843
844// CheckIconAttr
845static
846void
847CheckIconAttr(BNode &node, BBitmap *data)
848{
849	const char *attribute = NULL;
850	uint32 type = 0;
851	switch (data->Bounds().IntegerWidth()) {
852		case 15:
853			attribute = kMiniIconAttribute;
854			type = MINI_ICON_TYPE;
855			break;
856		case 31:
857			attribute = kLargeIconAttribute;
858			type = LARGE_ICON_TYPE;
859			break;
860		default:
861			CHK(false);
862			break;
863	}
864	CheckAttr(node, attribute, type, data->Bits(), data->BitsLength());
865}
866
867// CheckIconResource
868static
869void
870CheckIconResource(BFile &file, BBitmap *data)
871{
872	const char *attribute = NULL;
873	int32 resourceID = 0;
874	uint32 type = 0;
875	switch (data->Bounds().IntegerWidth()) {
876		case 15:
877			attribute = kMiniIconAttribute;
878			resourceID = kMiniIconResourceID;
879			type = MINI_ICON_TYPE;
880			break;
881		case 31:
882			attribute = kLargeIconAttribute;
883			resourceID = kLargeIconResourceID;
884			type = LARGE_ICON_TYPE;
885			break;
886		default:
887			CHK(false);
888			break;
889	}
890	CheckResource(file, attribute, resourceID, type, data->Bits(),
891				  data->BitsLength());
892}
893
894// CheckVersionInfoAttr
895static
896void
897CheckVersionInfoAttr(BNode &node, version_info *data)
898{
899	CheckAttr(node, kVersionInfoAttribute, VERSION_INFO_TYPE, data,
900			  2 * sizeof(version_info));
901}
902
903// CheckVersionInfoResource
904static
905void
906CheckVersionInfoResource(BFile &file, version_info *data)
907{
908	CheckResource(file, kVersionInfoAttribute, kVersionInfoResourceID,
909				  VERSION_INFO_TYPE, data, 2 * sizeof(version_info));
910}
911
912// CheckIconForTypeAttr
913static
914void
915CheckIconForTypeAttr(BNode &node, const char *type, BBitmap *data)
916{
917	string attribute;
918	int32 resourceID = 0;
919	uint32 iconType = 0;
920	switch (data->Bounds().IntegerWidth()) {
921		case 15:
922			attribute = kMiniIconForTypeAttribute;
923			resourceID = kMiniIconForTypeResourceID;
924			iconType = MINI_ICON_TYPE;
925			break;
926		case 31:
927			attribute = kLargeIconForTypeAttribute;
928			resourceID = kLargeIconForTypeResourceID;
929			iconType = LARGE_ICON_TYPE;
930			break;
931		default:
932			CHK(false);
933			break;
934	}
935	attribute += type;
936	CheckAttr(node, attribute.c_str(), iconType, data->Bits(),
937			  data->BitsLength());
938}
939
940// CheckIconForTypeResource
941static
942void
943CheckIconForTypeResource(BFile &file, const char *type, BBitmap *data,
944						 int32 resourceID = -1)
945{
946	string attribute;
947	uint32 iconType = 0;
948	switch (data->Bounds().IntegerWidth()) {
949		case 15:
950			attribute = kMiniIconForTypeAttribute;
951			if (resourceID < 0)
952				resourceID = kMiniIconForTypeResourceID;
953			iconType = MINI_ICON_TYPE;
954			break;
955		case 31:
956			attribute = kLargeIconForTypeAttribute;
957			if (resourceID < 0)
958				resourceID = kLargeIconForTypeResourceID;
959			iconType = LARGE_ICON_TYPE;
960			break;
961		default:
962			CHK(false);
963			break;
964	}
965	attribute += type;
966	CheckResource(file, attribute.c_str(), resourceID, iconType, data->Bits(),
967				  data->BitsLength());
968}
969
970// CheckNoIconForTypeAttr
971static
972void
973CheckNoIconForTypeAttr(BNode &node, const char *type, icon_size iconSize)
974{
975	string attribute;
976	switch (iconSize) {
977		case B_MINI_ICON:
978			attribute = kMiniIconForTypeAttribute;
979			break;
980		case B_LARGE_ICON:
981			attribute = kLargeIconForTypeAttribute;
982			break;
983		default:
984			CHK(false);
985			break;
986	}
987	attribute += type;
988	CheckNoAttr(node, attribute.c_str());
989}
990
991// CheckNoIconForTypeResource
992static
993void
994CheckNoIconForTypeResource(BFile &file, const char *type, icon_size iconSize)
995{
996	string attribute;
997	switch (iconSize) {
998		case B_MINI_ICON:
999			attribute = kMiniIconForTypeAttribute;
1000			break;
1001		case B_LARGE_ICON:
1002			attribute = kLargeIconForTypeAttribute;
1003			break;
1004		default:
1005			CHK(false);
1006			break;
1007	}
1008	attribute += type;
1009	CheckNoResource(file, attribute.c_str());
1010}
1011
1012
1013// InitTest1
1014void
1015AppFileInfoTest::InitTest1()
1016{
1017#ifdef TEST_R5
1018	const bool hasInitialLocation = false;
1019#else
1020	const bool hasInitialLocation = true;
1021#endif
1022	// BAppFileInfo()
1023	// * InitCheck() == B_NO_INIT
1024	NextSubTest();
1025	{
1026		BAppFileInfo appFileInfo;
1027		CHK(appFileInfo.InitCheck() == B_NO_INIT);
1028		CHK(appFileInfo.IsUsingAttributes() == hasInitialLocation);
1029		CHK(appFileInfo.IsUsingResources() == hasInitialLocation);
1030	}
1031
1032	// BAppFileInfo(BFile *file)
1033	// * NULL file => InitCheck() == B_BAD_VALUE
1034	NextSubTest();
1035	{
1036		BAppFileInfo appFileInfo(NULL);
1037		CHK(appFileInfo.InitCheck() == B_BAD_VALUE);
1038		CHK(appFileInfo.IsUsingAttributes() == hasInitialLocation);
1039		CHK(appFileInfo.IsUsingResources() == hasInitialLocation);
1040	}
1041	// * invalid file => InitCheck() == B_BAD_VALUE
1042	NextSubTest();
1043	{
1044		BFile file;
1045		BAppFileInfo appFileInfo(&file);
1046		CHK(appFileInfo.InitCheck() == B_BAD_VALUE);
1047		CHK(appFileInfo.IsUsingAttributes() == hasInitialLocation);
1048		CHK(appFileInfo.IsUsingResources() == hasInitialLocation);
1049	}
1050	// * valid file => InitCheck() == B_OK
1051	NextSubTest();
1052	{
1053		BFile file(testFile1, B_READ_WRITE);
1054		BAppFileInfo appFileInfo(&file);
1055		CHK(appFileInfo.InitCheck() == B_OK);
1056		CHK(appFileInfo.IsUsingAttributes() == true);
1057		CHK(appFileInfo.IsUsingResources() == true);
1058	}
1059}
1060
1061// InitTest2
1062void
1063AppFileInfoTest::InitTest2()
1064{
1065#ifdef TEST_R5
1066	const bool hasInitialLocation = false;
1067#else
1068	const bool hasInitialLocation = true;
1069#endif
1070	// status_t SetTo(BFile *file)
1071	// * NULL file => InitCheck() == B_NO_INIT
1072	NextSubTest();
1073	{
1074		BAppFileInfo appFileInfo;
1075		CHK(appFileInfo.SetTo(NULL) == B_BAD_VALUE);
1076		CHK(appFileInfo.InitCheck() == B_BAD_VALUE);
1077		CHK(appFileInfo.IsUsingAttributes() == hasInitialLocation);
1078		CHK(appFileInfo.IsUsingResources() == hasInitialLocation);
1079	}
1080	// * invalid file => InitCheck() == B_BAD_VALUE
1081	NextSubTest();
1082	{
1083		BFile file;
1084		BAppFileInfo appFileInfo;
1085		CHK(appFileInfo.SetTo(&file) == B_BAD_VALUE);
1086		CHK(appFileInfo.InitCheck() == B_BAD_VALUE);
1087		CHK(appFileInfo.IsUsingAttributes() == hasInitialLocation);
1088		CHK(appFileInfo.IsUsingResources() == hasInitialLocation);
1089	}
1090	// * valid file => InitCheck() == B_OK
1091	// * reinitialize invalid/valid => InitCheck() == B_BAD_VALUE/B_OK
1092	NextSubTest();
1093	{
1094		BFile file(testFile1, B_READ_WRITE);
1095		BAppFileInfo appFileInfo;
1096		CHK(appFileInfo.SetTo(&file) == B_OK);
1097		CHK(appFileInfo.InitCheck() == B_OK);
1098		CHK(appFileInfo.IsUsingAttributes() == true);
1099		CHK(appFileInfo.IsUsingResources() == true);
1100		off_t size;
1101		CHK(file.GetSize(&size) == B_OK);
1102		CHK(size == 0);
1103		CheckNoAttr(file, kTypeAttribute);
1104		CheckNoAttr(file, kMiniIconAttribute);
1105		CheckNoAttr(file, kLargeIconAttribute);
1106		// reinit with NULL file
1107		CHK(appFileInfo.SetTo(NULL) == B_BAD_VALUE);
1108		CHK(appFileInfo.InitCheck() == B_BAD_VALUE);
1109		CHK(appFileInfo.IsUsingAttributes() == true);
1110		CHK(appFileInfo.IsUsingResources() == true);
1111		CHK(file.GetSize(&size) == B_OK);
1112		CHK(size == 0);
1113		CheckNoAttr(file, kTypeAttribute);
1114		CheckNoAttr(file, kMiniIconAttribute);
1115		CheckNoAttr(file, kLargeIconAttribute);
1116		// reinit with valid file
1117		BFile file2(testFile2, B_READ_WRITE);
1118		CHK(appFileInfo.SetTo(&file2) == B_OK);
1119		CHK(appFileInfo.InitCheck() == B_OK);
1120		CHK(appFileInfo.IsUsingAttributes() == true);
1121		CHK(appFileInfo.IsUsingResources() == true);
1122	}
1123}
1124
1125// TypeTest
1126void
1127AppFileInfoTest::TypeTest()
1128{
1129	// status_t GetType(char *type) const
1130	// * NULL type => B_BAD_ADDRESS/B_BAD_VALUE
1131	NextSubTest();
1132	{
1133		BFile file(testFile1, B_READ_WRITE);
1134		BAppFileInfo appFileInfo;
1135		CHK(appFileInfo.SetTo(&file) == B_OK);
1136		CHK(equals(appFileInfo.GetType(NULL), B_BAD_ADDRESS, B_BAD_VALUE));
1137	}
1138	// * uninitialized => B_NO_INIT
1139	NextSubTest();
1140	{
1141		BAppFileInfo appFileInfo;
1142		char type[B_MIME_TYPE_LENGTH];
1143		CHK(appFileInfo.GetType(type) == B_NO_INIT);
1144	}
1145	// * has no type => B_ENTRY_NOT_FOUND
1146	NextSubTest();
1147	{
1148		BFile file(testFile1, B_READ_WRITE);
1149		BAppFileInfo appFileInfo;
1150		CHK(appFileInfo.SetTo(&file) == B_OK);
1151		char type[B_MIME_TYPE_LENGTH];
1152		CHK(appFileInfo.GetType(type) == B_ENTRY_NOT_FOUND);
1153	}
1154	// * set, get, reset, get
1155	NextSubTest();
1156	{
1157		BFile file(testFile1, B_READ_WRITE);
1158		BAppFileInfo appFileInfo;
1159		CHK(appFileInfo.SetTo(&file) == B_OK);
1160		// set
1161		CHK(appFileInfo.SetType(testType1) == B_OK);
1162		// get
1163		char type[B_MIME_TYPE_LENGTH];
1164		CHK(appFileInfo.GetType(type) == B_OK);
1165		CHK(strcmp(testType1, type) == 0);
1166		CheckTypeAttr(file, testType1);
1167		SyncResources(appFileInfo);
1168		CheckTypeResource(file, testType1);
1169		// reset
1170		CHK(appFileInfo.SetType(testType2) == B_OK);
1171		// get
1172		CHK(appFileInfo.GetType(type) == B_OK);
1173		CHK(strcmp(testType2, type) == 0);
1174		CheckTypeAttr(file, testType2);
1175		SyncResources(appFileInfo);
1176		CheckTypeResource(file, testType2);
1177	}
1178
1179	// status_t SetType(const char *type)
1180	// * NULL type => B_OK, unsets the type
1181	NextSubTest();
1182	{
1183		BFile file(testFile1, B_READ_WRITE);
1184		BAppFileInfo appFileInfo;
1185		CHK(appFileInfo.SetTo(&file) == B_OK);
1186		CHK(appFileInfo.SetType(NULL) == B_OK);
1187		// get
1188		char type[B_MIME_TYPE_LENGTH];
1189		CHK(appFileInfo.GetType(type) == B_ENTRY_NOT_FOUND);
1190		CheckNoAttr(file, kTypeAttribute);
1191		SyncResources(appFileInfo);
1192		CheckNoResource(file, kTypeAttribute);
1193	}
1194	// * uninitialized => B_NO_INIT
1195	NextSubTest();
1196	{
1197		BAppFileInfo appFileInfo;
1198		CHK(appFileInfo.SetType(testType1) == B_NO_INIT);
1199	}
1200	// * invalid MIME type => B_OK
1201	NextSubTest();
1202	{
1203		BFile file(testFile1, B_READ_WRITE);
1204		BAppFileInfo appFileInfo;
1205		CHK(appFileInfo.SetTo(&file) == B_OK);
1206		CHK(appFileInfo.SetType(invalidTestType) == B_OK);
1207		// get
1208		char type[B_MIME_TYPE_LENGTH];
1209		CHK(appFileInfo.GetType(type) == B_OK);
1210		CHK(strcmp(invalidTestType, type) == 0);
1211		CheckTypeAttr(file, invalidTestType);
1212		SyncResources(appFileInfo);
1213		CheckTypeResource(file, invalidTestType);
1214	}
1215	// * type string too long => B_BAD_VALUE
1216	NextSubTest();
1217	{
1218		BFile file(testFile1, B_READ_WRITE);
1219		BAppFileInfo appFileInfo;
1220		CHK(appFileInfo.SetTo(&file) == B_OK);
1221		// remove attr first
1222		CHK(appFileInfo.SetType(NULL) == B_OK);
1223		// try to set the too long type
1224		CHK(appFileInfo.SetType(tooLongTestType) == B_BAD_VALUE);
1225		CheckNoAttr(file, kTypeAttribute);
1226		SyncResources(appFileInfo);
1227		CheckNoResource(file, kTypeAttribute);
1228	}
1229}
1230
1231// SignatureTest
1232void
1233AppFileInfoTest::SignatureTest()
1234{
1235	// status_t GetSignature(char *signature) const
1236	// * NULL signature => B_BAD_ADDRESS/B_BAD_VALUE
1237	NextSubTest();
1238	{
1239		BFile file(testFile1, B_READ_WRITE);
1240		BAppFileInfo appFileInfo;
1241		CHK(appFileInfo.SetTo(&file) == B_OK);
1242		CHK(equals(appFileInfo.GetSignature(NULL), B_BAD_ADDRESS, B_BAD_VALUE));
1243	}
1244	// * uninitialized => B_NO_INIT
1245	NextSubTest();
1246	{
1247		BAppFileInfo appFileInfo;
1248		char signature[B_MIME_TYPE_LENGTH];
1249		CHK(appFileInfo.GetSignature(signature) == B_NO_INIT);
1250	}
1251	// * has no signature => B_ENTRY_NOT_FOUND
1252	NextSubTest();
1253	{
1254		BFile file(testFile1, B_READ_WRITE);
1255		BAppFileInfo appFileInfo;
1256		CHK(appFileInfo.SetTo(&file) == B_OK);
1257		char signature[B_MIME_TYPE_LENGTH];
1258		CHK(appFileInfo.GetSignature(signature) == B_ENTRY_NOT_FOUND);
1259	}
1260	// * set, get, reset, get
1261	NextSubTest();
1262	{
1263		BFile file(testFile1, B_READ_WRITE);
1264		BAppFileInfo appFileInfo;
1265		CHK(appFileInfo.SetTo(&file) == B_OK);
1266		// set
1267		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1268		CHK(BMimeType(testAppSignature1).IsInstalled() == false);
1269		// get
1270		char signature[B_MIME_TYPE_LENGTH];
1271		CHK(appFileInfo.GetSignature(signature) == B_OK);
1272		CHK(strcmp(testAppSignature1, signature) == 0);
1273		CheckSignatureAttr(file, testAppSignature1);
1274		SyncResources(appFileInfo);
1275		CheckSignatureResource(file, testAppSignature1);
1276		// reset
1277		CHK(appFileInfo.SetSignature(testAppSignature2) == B_OK);
1278		CHK(BMimeType(testAppSignature2).IsInstalled() == false);
1279		// get
1280		CHK(appFileInfo.GetSignature(signature) == B_OK);
1281		CHK(strcmp(testAppSignature2, signature) == 0);
1282		CheckSignatureAttr(file, testAppSignature2);
1283		SyncResources(appFileInfo);
1284		CheckSignatureResource(file, testAppSignature2);
1285	}
1286
1287	// status_t SetSignature(const char *signature)
1288	// * NULL signature => B_OK, unsets the signature
1289	NextSubTest();
1290	{
1291		BFile file(testFile1, B_READ_WRITE);
1292		BAppFileInfo appFileInfo;
1293		CHK(appFileInfo.SetTo(&file) == B_OK);
1294		CHK(appFileInfo.SetSignature(NULL) == B_OK);
1295		// get
1296		char signature[B_MIME_TYPE_LENGTH];
1297		CHK(appFileInfo.GetSignature(signature) == B_ENTRY_NOT_FOUND);
1298		CheckNoAttr(file, kSignatureAttribute);
1299		SyncResources(appFileInfo);
1300		CheckNoResource(file, kSignatureAttribute);
1301	}
1302	// * uninitialized => B_NO_INIT
1303	NextSubTest();
1304	{
1305		BAppFileInfo appFileInfo;
1306		CHK(appFileInfo.SetSignature(testAppSignature1) == B_NO_INIT);
1307	}
1308	// * invalid MIME signature => B_OK
1309	NextSubTest();
1310	{
1311		BFile file(testFile1, B_READ_WRITE);
1312		BAppFileInfo appFileInfo;
1313		CHK(appFileInfo.SetTo(&file) == B_OK);
1314		CHK(appFileInfo.SetSignature(invalidTestType) == B_OK);
1315		// get
1316		char signature[B_MIME_TYPE_LENGTH];
1317		CHK(appFileInfo.GetSignature(signature) == B_OK);
1318		CHK(strcmp(invalidTestType, signature) == 0);
1319		CheckSignatureAttr(file, invalidTestType);
1320		SyncResources(appFileInfo);
1321		CheckSignatureResource(file, invalidTestType);
1322	}
1323	// * signature string too long => B_BAD_VALUE
1324	NextSubTest();
1325	{
1326		BFile file(testFile1, B_READ_WRITE);
1327		BAppFileInfo appFileInfo;
1328		CHK(appFileInfo.SetTo(&file) == B_OK);
1329		// remove attr first
1330		CHK(appFileInfo.SetSignature(NULL) == B_OK);
1331		// try to set the too long signature
1332		CHK(appFileInfo.SetSignature(tooLongTestType) == B_BAD_VALUE);
1333		CheckNoAttr(file, kSignatureAttribute);
1334		SyncResources(appFileInfo);
1335		CheckNoResource(file, kSignatureAttribute);
1336	}
1337}
1338
1339// AppFlagsTest
1340void
1341AppFileInfoTest::AppFlagsTest()
1342{
1343	// status_t GetAppFlags(uint32 *flags) const
1344	// * NULL flags => B_BAD_ADDRESS/B_BAD_VALUE
1345	NextSubTest();
1346	{
1347		BFile file(testFile1, B_READ_WRITE);
1348		BAppFileInfo appFileInfo;
1349		CHK(appFileInfo.SetTo(&file) == B_OK);
1350		CHK(equals(appFileInfo.GetAppFlags(NULL), B_BAD_ADDRESS, B_BAD_VALUE));
1351	}
1352	// * uninitialized => B_NO_INIT
1353	NextSubTest();
1354	{
1355		BAppFileInfo appFileInfo;
1356		uint32 flags;
1357		CHK(appFileInfo.GetAppFlags(&flags) == B_NO_INIT);
1358	}
1359	// * has no flags => B_ENTRY_NOT_FOUND
1360	NextSubTest();
1361	{
1362		BFile file(testFile1, B_READ_WRITE);
1363		BAppFileInfo appFileInfo;
1364		CHK(appFileInfo.SetTo(&file) == B_OK);
1365		uint32 flags;
1366		CHK(appFileInfo.GetAppFlags(&flags) == B_ENTRY_NOT_FOUND);
1367	}
1368	// * set, get, reset, get
1369	NextSubTest();
1370	{
1371		uint32 testFlags1 = B_SINGLE_LAUNCH | B_BACKGROUND_APP;
1372		uint32 testFlags2 = B_MULTIPLE_LAUNCH | B_ARGV_ONLY;
1373		BFile file(testFile1, B_READ_WRITE);
1374		BAppFileInfo appFileInfo;
1375		CHK(appFileInfo.SetTo(&file) == B_OK);
1376		// set
1377		CHK(appFileInfo.SetAppFlags(testFlags1) == B_OK);
1378		// get
1379		uint32 flags;
1380		CHK(appFileInfo.GetAppFlags(&flags) == B_OK);
1381		CHK(flags == testFlags1);
1382		CheckAppFlagsAttr(file, testFlags1);
1383		SyncResources(appFileInfo);
1384		CheckAppFlagsResource(file, testFlags1);
1385		// reset
1386		CHK(appFileInfo.SetAppFlags(testFlags2) == B_OK);
1387		// get
1388		CHK(appFileInfo.GetAppFlags(&flags) == B_OK);
1389		CHK(flags == testFlags2);
1390		CheckAppFlagsAttr(file, testFlags2);
1391		SyncResources(appFileInfo);
1392		CheckAppFlagsResource(file, testFlags2);
1393	}
1394
1395	// status_t SetAppFlags(uint32 flags)
1396	// * uninitialized => B_NO_INIT
1397	NextSubTest();
1398	{
1399		BAppFileInfo appFileInfo;
1400		CHK(appFileInfo.SetAppFlags(B_SINGLE_LAUNCH) == B_NO_INIT);
1401	}
1402}
1403
1404// IsSupportingApp
1405static
1406bool
1407IsSupportingApp(const char *type, const char *signature)
1408{
1409	BMessage apps;
1410//	CHK(BMimeType(type).GetSupportingApps(&apps) == B_OK);
1411	BMimeType(type).GetSupportingApps(&apps);
1412	bool found = false;
1413	BString app;
1414	for (int32 i = 0;
1415		 !found && apps.FindString("applications", i, &app) == B_OK;
1416		 i++) {
1417		found = (app == signature);
1418	}
1419	return found;
1420}
1421
1422// SupportedTypesTest
1423void
1424AppFileInfoTest::SupportedTypesTest()
1425{
1426	// test data
1427	BMessage testTypes1;
1428	CHK(testTypes1.AddString("types", testType1) == B_OK);
1429	CHK(testTypes1.AddString("types", testType2) == B_OK);
1430	BMessage testTypes2;
1431	CHK(testTypes2.AddString("types", testType3) == B_OK);
1432	CHK(testTypes2.AddString("types", testType4) == B_OK);
1433	BMimeType mimeTestType1(testType1);
1434	BMimeType mimeTestType2(testType2);
1435	BMimeType mimeTestType3(testType3);
1436	BMimeType mimeTestType4(testType4);
1437	// add and install the app signature
1438	{
1439		BFile file(testFile1, B_READ_WRITE);
1440		BAppFileInfo appFileInfo;
1441		CHK(appFileInfo.SetTo(&file) == B_OK);
1442		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1443		CHK(BMimeType(testAppSignature1).Install() == B_OK);
1444	}
1445
1446	// status_t GetSupportedTypes(BMessage *types) const;
1447	// * uninitialized => B_NO_INIT
1448	NextSubTest();
1449	{
1450		BAppFileInfo appFileInfo;
1451		BMessage types;
1452		CHK(appFileInfo.GetSupportedTypes(&types) == B_NO_INIT);
1453	}
1454	// * has no supported types => B_ENTRY_NOT_FOUND
1455	NextSubTest();
1456	{
1457		BFile file(testFile1, B_READ_WRITE);
1458		BAppFileInfo appFileInfo;
1459		CHK(appFileInfo.SetTo(&file) == B_OK);
1460		BMessage types;
1461		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1462	}
1463	// * set, get, reset, get
1464	NextSubTest();
1465	{
1466		BFile file(testFile1, B_READ_WRITE);
1467		BAppFileInfo appFileInfo;
1468		CHK(appFileInfo.SetTo(&file) == B_OK);
1469		// set
1470		CHK(BMimeType(testType1).IsInstalled() == false);
1471		CHK(BMimeType(testType2).IsInstalled() == false);
1472		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_OK);
1473		// get
1474		BMessage types;
1475		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1476		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes1));
1477		CHK(appFileInfo.IsSupportedType(testType1) == true);
1478		CHK(appFileInfo.IsSupportedType(testType2) == true);
1479		CHK(appFileInfo.Supports(&mimeTestType1) == true);
1480		CHK(appFileInfo.Supports(&mimeTestType2) == true);
1481		CheckSupportedTypesAttr(file, &testTypes1);
1482		SyncResources(appFileInfo);
1483		CheckSupportedTypesResource(file, &testTypes1);
1484		CHK(BMimeType(testType1).IsInstalled() == true);
1485		CHK(BMimeType(testType2).IsInstalled() == true);
1486		// reset
1487		CHK(BMimeType(testType3).IsInstalled() == false);
1488		CHK(BMimeType(testType4).IsInstalled() == false);
1489		CHK(appFileInfo.SetSupportedTypes(&testTypes2) == B_OK);
1490		// get
1491		BMessage types2;
1492		CHK(appFileInfo.GetSupportedTypes(&types2) == B_OK);
1493		CHK(SupportedTypesValue(types2) == SupportedTypesValue(testTypes2));
1494		CHK(appFileInfo.IsSupportedType(testType1) == false);
1495		CHK(appFileInfo.IsSupportedType(testType2) == false);
1496		CHK(appFileInfo.IsSupportedType(testType3) == true);
1497		CHK(appFileInfo.IsSupportedType(testType4) == true);
1498		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1499		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1500		CHK(appFileInfo.Supports(&mimeTestType3) == true);
1501		CHK(appFileInfo.Supports(&mimeTestType4) == true);
1502		CheckSupportedTypesAttr(file, &testTypes2);
1503		SyncResources(appFileInfo);
1504		CheckSupportedTypesResource(file, &testTypes2);
1505		CHK(BMimeType(testType3).IsInstalled() == true);
1506		CHK(BMimeType(testType4).IsInstalled() == true);
1507	}
1508	// * partially filled types => types is cleared beforehand
1509	NextSubTest();
1510	{
1511		BFile file(testFile1, B_READ_WRITE);
1512		BAppFileInfo appFileInfo;
1513		CHK(appFileInfo.SetTo(&file) == B_OK);
1514		BMessage types2;
1515		CHK(types2.AddString("types", testType1) == B_OK);
1516		CHK(types2.AddString("dummy", "Hello") == B_OK);
1517		CHK(appFileInfo.GetSupportedTypes(&types2) == B_OK);
1518		CHK(SupportedTypesValue(types2) == SupportedTypesValue(testTypes2));
1519		const char *dummy;
1520		CHK(types2.FindString("dummy", &dummy) != B_OK);
1521	}
1522	// * NULL types => B_BAD_VALUE
1523// R5: crashes when passing NULL types
1524#ifndef TEST_R5
1525	NextSubTest();
1526	{
1527		BFile file(testFile1, B_READ_WRITE);
1528		BAppFileInfo appFileInfo;
1529		CHK(appFileInfo.SetTo(&file) == B_OK);
1530		CHK(appFileInfo.GetSupportedTypes(NULL) == B_BAD_VALUE);
1531	}
1532#endif
1533
1534	// status_t SetSupportedTypes(const BMessage *types, bool syncAll);
1535	// status_t SetSupportedTypes(const BMessage *types);
1536	// * uninitialized => B_NO_INIT
1537	NextSubTest();
1538	{
1539		BAppFileInfo appFileInfo;
1540		BMessage types;
1541		CHK(appFileInfo.SetSupportedTypes(&types) == B_NO_INIT);
1542	}
1543	// * NULL types => unsets supported types
1544	NextSubTest();
1545	{
1546		BFile file(testFile1, B_READ_WRITE);
1547		BAppFileInfo appFileInfo;
1548		CHK(appFileInfo.SetTo(&file) == B_OK);
1549		// set
1550		CHK(appFileInfo.SetSupportedTypes(NULL) == B_OK);
1551		// get
1552		BMessage types;
1553		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1554		CHK(appFileInfo.IsSupportedType(testType1) == false);
1555		CHK(appFileInfo.IsSupportedType(testType2) == false);
1556		CHK(appFileInfo.IsSupportedType(testType3) == false);
1557		CHK(appFileInfo.IsSupportedType(testType4) == false);
1558		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1559		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1560		CHK(appFileInfo.Supports(&mimeTestType3) == false);
1561		CHK(appFileInfo.Supports(&mimeTestType4) == false);
1562		CheckNoAttr(file, kSupportedTypesAttribute);
1563		SyncResources(appFileInfo);
1564		CheckNoResource(file, kSupportedTypesAttribute);
1565		// set: syncAll = true
1566// R5: crashes when passing NULL types
1567#ifndef TEST_R5
1568		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_OK);
1569		CHK(appFileInfo.SetSupportedTypes(NULL, true) == B_OK);
1570		// get
1571		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1572		CHK(appFileInfo.IsSupportedType(testType1) == false);
1573		CHK(appFileInfo.IsSupportedType(testType2) == false);
1574		CHK(appFileInfo.IsSupportedType(testType3) == false);
1575		CHK(appFileInfo.IsSupportedType(testType4) == false);
1576		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1577		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1578		CHK(appFileInfo.Supports(&mimeTestType3) == false);
1579		CHK(appFileInfo.Supports(&mimeTestType4) == false);
1580		CheckNoAttr(file, kSupportedTypesAttribute);
1581		SyncResources(appFileInfo);
1582		CheckNoResource(file, kSupportedTypesAttribute);
1583#endif
1584	}
1585	// * cross check with BMimeType::GetSupportingApps(): no syncAll
1586	NextSubTest();
1587	{
1588		// clean up
1589		CHK(BMimeType(testType1).Delete() == B_OK);
1590		CHK(BMimeType(testType2).Delete() == B_OK);
1591		CHK(BMimeType(testType3).Delete() == B_OK);
1592		CHK(BMimeType(testType4).Delete() == B_OK);
1593		CHK(BMimeType(testAppSignature1).Delete() == B_OK);
1594		CHK(BMimeType(testAppSignature1).Install() == B_OK);
1595		CHK(BEntry(testFile1).Remove() == B_OK);
1596		// init
1597		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1598		BAppFileInfo appFileInfo;
1599		CHK(appFileInfo.SetTo(&file) == B_OK);
1600		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1601		// set
1602		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_OK);
1603		// get
1604		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1605		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1606		// reset
1607		CHK(appFileInfo.SetSupportedTypes(&testTypes2) == B_OK);
1608		// get
1609		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1610		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1611		CHK(IsSupportingApp(testType3, testAppSignature1) == true);
1612		CHK(IsSupportingApp(testType4, testAppSignature1) == true);
1613	}
1614	// * cross check with BMimeType::GetSupportingApps(): syncAll == false
1615	NextSubTest();
1616	{
1617		// clean up
1618		CHK(BMimeType(testType1).Delete() == B_OK);
1619		CHK(BMimeType(testType2).Delete() == B_OK);
1620		CHK(BMimeType(testType3).Delete() == B_OK);
1621		CHK(BMimeType(testType4).Delete() == B_OK);
1622		CHK(BMimeType(testAppSignature1).Delete() == B_OK);
1623		CHK(BMimeType(testAppSignature1).Install() == B_OK);
1624		CHK(BEntry(testFile1).Remove() == B_OK);
1625		// init
1626		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1627		BAppFileInfo appFileInfo;
1628		CHK(appFileInfo.SetTo(&file) == B_OK);
1629		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1630		// set
1631		CHK(appFileInfo.SetSupportedTypes(&testTypes1, false) == B_OK);
1632		// get
1633		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1634		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1635		// reset
1636		CHK(appFileInfo.SetSupportedTypes(&testTypes2, false) == B_OK);
1637		// get
1638		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1639		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1640		CHK(IsSupportingApp(testType3, testAppSignature1) == true);
1641		CHK(IsSupportingApp(testType4, testAppSignature1) == true);
1642	}
1643	// * cross check with BMimeType::GetSupportingApps(): syncAll == true
1644	NextSubTest();
1645	{
1646		// clean up
1647		CHK(BMimeType(testType1).Delete() == B_OK);
1648		CHK(BMimeType(testType2).Delete() == B_OK);
1649		CHK(BMimeType(testType3).Delete() == B_OK);
1650		CHK(BMimeType(testType4).Delete() == B_OK);
1651		CHK(BMimeType(testAppSignature1).Delete() == B_OK);
1652		CHK(BMimeType(testAppSignature1).Install() == B_OK);
1653		CHK(BEntry(testFile1).Remove() == B_OK);
1654		// init
1655		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1656		BAppFileInfo appFileInfo;
1657		CHK(appFileInfo.SetTo(&file) == B_OK);
1658		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1659		// set
1660		CHK(appFileInfo.SetSupportedTypes(&testTypes1, true) == B_OK);
1661		// get
1662		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1663		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1664		// reset
1665		CHK(appFileInfo.SetSupportedTypes(&testTypes2, true) == B_OK);
1666		// get
1667		CHK(IsSupportingApp(testType1, testAppSignature1) == false);
1668		CHK(IsSupportingApp(testType2, testAppSignature1) == false);
1669		CHK(IsSupportingApp(testType3, testAppSignature1) == true);
1670		CHK(IsSupportingApp(testType4, testAppSignature1) == true);
1671	}
1672	// * types contains invalid MIME types
1673// R5: doesn't fail
1674#ifndef TEST_R5
1675	NextSubTest();
1676	{
1677		// init
1678		BFile file(testFile1, B_READ_WRITE);
1679		BAppFileInfo appFileInfo;
1680		CHK(appFileInfo.SetTo(&file) == B_OK);
1681		// set
1682		BMessage invalidTestTypes;
1683		CHK(invalidTestTypes.AddString("types", invalidTestType) == B_OK);
1684		CHK(appFileInfo.SetSupportedTypes(NULL, true) == B_OK);
1685		CHK(appFileInfo.SetSupportedTypes(&invalidTestTypes, false)
1686			== B_BAD_VALUE);
1687		// get
1688		BMessage types;
1689		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1690		CHK(appFileInfo.IsSupportedType(invalidTestType) == false);
1691		CheckNoAttr(file, kSupportedTypesAttribute);
1692		SyncResources(appFileInfo);
1693		CheckNoResource(file, kSupportedTypesAttribute);
1694	}
1695#endif
1696
1697	// bool IsSupportedType(const char *type) const;
1698	// bool Supports(BMimeType *type) const;
1699	// * NULL type => false
1700	NextSubTest();
1701	{
1702		BFile file(testFile1, B_READ_WRITE);
1703		BAppFileInfo appFileInfo;
1704		CHK(appFileInfo.SetTo(&file) == B_OK);
1705		CHK(appFileInfo.IsSupportedType(NULL) == false);
1706// R5: crashes when passing a NULL type
1707#ifndef TEST_R5
1708		CHK(appFileInfo.Supports(NULL) == false);
1709#endif
1710	}
1711	// * supports "application/octet-stream"
1712	NextSubTest();
1713	{
1714		BFile file(testFile1, B_READ_WRITE);
1715		BAppFileInfo appFileInfo;
1716		CHK(appFileInfo.SetTo(&file) == B_OK);
1717		BMimeType gifType("image/gif");
1718		CHK(appFileInfo.IsSupportedType(gifType.Type()) == false);
1719		CHK(appFileInfo.Supports(&gifType) == false);
1720		BMessage types;
1721		CHK(types.AddString("types", "application/octet-stream") == B_OK);
1722		CHK(appFileInfo.SetSupportedTypes(&types) == B_OK);
1723		CHK(appFileInfo.IsSupportedType(gifType.Type()) == true);
1724		CHK(appFileInfo.Supports(&gifType) == false);
1725		BMessage noTypes;
1726		CHK(appFileInfo.SetSupportedTypes(&noTypes, true) == B_OK);
1727	}
1728
1729	// various
1730	// * signature not installed, syncAll = true
1731	NextSubTest();
1732	{
1733		// clean up
1734		CHK(BMimeType(testType1).Delete() == B_OK);
1735		CHK(BMimeType(testType2).Delete() == B_OK);
1736		CHK(BMimeType(testType3).Delete() == B_OK);
1737		CHK(BMimeType(testType4).Delete() == B_OK);
1738		CHK(BMimeType(testAppSignature1).Delete() == B_OK);
1739		CHK(BEntry(testFile1).Remove() == B_OK);
1740		// init
1741		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1742		BAppFileInfo appFileInfo;
1743		CHK(appFileInfo.SetTo(&file) == B_OK);
1744		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1745		// set
1746		CHK(BMimeType(testType1).IsInstalled() == false);
1747		CHK(BMimeType(testType2).IsInstalled() == false);
1748		CHK(appFileInfo.SetSupportedTypes(&testTypes1, true) == B_OK);
1749		// get
1750		BMessage types;
1751		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1752		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes1));
1753		CHK(appFileInfo.IsSupportedType(testType1) == true);
1754		CHK(appFileInfo.IsSupportedType(testType2) == true);
1755		CHK(appFileInfo.Supports(&mimeTestType1) == true);
1756		CHK(appFileInfo.Supports(&mimeTestType2) == true);
1757		CheckSupportedTypesAttr(file, &testTypes1);
1758		SyncResources(appFileInfo);
1759		CheckSupportedTypesResource(file, &testTypes1);
1760		CHK(BMimeType(testType1).IsInstalled() == false);
1761		CHK(BMimeType(testType2).IsInstalled() == false);
1762		// set
1763		CHK(BMimeType(testType3).IsInstalled() == false);
1764		CHK(BMimeType(testType4).IsInstalled() == false);
1765		CHK(appFileInfo.SetSupportedTypes(&testTypes2, true) == B_OK);
1766		// get
1767		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1768		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes2));
1769		CHK(appFileInfo.IsSupportedType(testType1) == false);
1770		CHK(appFileInfo.IsSupportedType(testType2) == false);
1771		CHK(appFileInfo.IsSupportedType(testType3) == true);
1772		CHK(appFileInfo.IsSupportedType(testType4) == true);
1773		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1774		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1775		CHK(appFileInfo.Supports(&mimeTestType3) == true);
1776		CHK(appFileInfo.Supports(&mimeTestType4) == true);
1777		CheckSupportedTypesAttr(file, &testTypes2);
1778		SyncResources(appFileInfo);
1779		CheckSupportedTypesResource(file, &testTypes2);
1780		CHK(BMimeType(testType1).IsInstalled() == false);
1781		CHK(BMimeType(testType2).IsInstalled() == false);
1782		CHK(BMimeType(testType3).IsInstalled() == false);
1783// R5: returns true. In fact the last SetSupportedTypes() installed testType4
1784// in the database, but not testType3. Certainly a bug
1785#ifndef TEST_R5
1786		CHK(BMimeType(testType4).IsInstalled() == false);
1787#endif
1788	}
1789	// * signature not installed, no syncAll
1790	NextSubTest();
1791	{
1792		// clean up
1793		BMimeType(testType1).Delete();
1794		BMimeType(testType2).Delete();
1795		BMimeType(testType3).Delete();
1796		BMimeType(testType4).Delete();
1797		BMimeType(testAppSignature1).Delete();
1798		CHK(BEntry(testFile1).Remove() == B_OK);
1799		// init
1800		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1801		BAppFileInfo appFileInfo;
1802		CHK(appFileInfo.SetTo(&file) == B_OK);
1803		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1804		// set
1805		CHK(BMimeType(testType1).IsInstalled() == false);
1806		CHK(BMimeType(testType2).IsInstalled() == false);
1807// R5: SetSupportedTypes() returns B_ENTRY_NOT_FOUND, although it does not
1808//     fail.
1809#ifdef TEST_R5
1810		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_ENTRY_NOT_FOUND);
1811#else
1812		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_OK);
1813#endif
1814		// get
1815		BMessage types;
1816		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1817		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes1));
1818		CHK(appFileInfo.IsSupportedType(testType1) == true);
1819		CHK(appFileInfo.IsSupportedType(testType2) == true);
1820		CHK(appFileInfo.Supports(&mimeTestType1) == true);
1821		CHK(appFileInfo.Supports(&mimeTestType2) == true);
1822		CheckSupportedTypesAttr(file, &testTypes1);
1823		SyncResources(appFileInfo);
1824		CheckSupportedTypesResource(file, &testTypes1);
1825		CHK(BMimeType(testType1).IsInstalled() == false);
1826		CHK(BMimeType(testType2).IsInstalled() == false);
1827		// set
1828		CHK(BMimeType(testType3).IsInstalled() == false);
1829		CHK(BMimeType(testType4).IsInstalled() == false);
1830// R5: SetSupportedTypes() returns B_ENTRY_NOT_FOUND, although it does not
1831//     fail.
1832#ifdef TEST_R5
1833		CHK(appFileInfo.SetSupportedTypes(&testTypes2) == B_ENTRY_NOT_FOUND);
1834#else
1835		CHK(appFileInfo.SetSupportedTypes(&testTypes2) == B_OK);
1836#endif
1837		// get
1838		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1839		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes2));
1840		CHK(appFileInfo.IsSupportedType(testType1) == false);
1841		CHK(appFileInfo.IsSupportedType(testType2) == false);
1842		CHK(appFileInfo.IsSupportedType(testType3) == true);
1843		CHK(appFileInfo.IsSupportedType(testType4) == true);
1844		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1845		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1846		CHK(appFileInfo.Supports(&mimeTestType3) == true);
1847		CHK(appFileInfo.Supports(&mimeTestType4) == true);
1848		CheckSupportedTypesAttr(file, &testTypes2);
1849		SyncResources(appFileInfo);
1850		CheckSupportedTypesResource(file, &testTypes2);
1851		CHK(BMimeType(testType1).IsInstalled() == false);
1852		CHK(BMimeType(testType2).IsInstalled() == false);
1853		CHK(BMimeType(testType3).IsInstalled() == false);
1854// R5: returns true. In fact the last SetSupportedTypes() installed testType4
1855// in the database, but not testType3. Certainly a bug
1856#ifndef TEST_R5
1857		CHK(BMimeType(testType4).IsInstalled() == false);
1858#endif
1859	}
1860	// * no signature
1861	NextSubTest();
1862	{
1863		// clean up
1864		BMimeType(testType1).Delete();
1865		BMimeType(testType2).Delete();
1866		BMimeType(testType3).Delete();
1867		BMimeType(testType4).Delete();
1868		BMimeType(testAppSignature1).Delete();
1869		CHK(BEntry(testFile1).Remove() == B_OK);
1870		// init
1871		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1872		BAppFileInfo appFileInfo;
1873		CHK(appFileInfo.SetTo(&file) == B_OK);
1874		// set, syncAll = true
1875		CHK(BMimeType(testType1).IsInstalled() == false);
1876		CHK(BMimeType(testType2).IsInstalled() == false);
1877		CHK(appFileInfo.SetSupportedTypes(&testTypes1, true)
1878			== B_ENTRY_NOT_FOUND);
1879		// get
1880		BMessage types;
1881		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1882		CHK(appFileInfo.IsSupportedType(testType1) == false);
1883		CHK(appFileInfo.IsSupportedType(testType2) == false);
1884		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1885		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1886		CheckNoAttr(file, kSupportedTypesAttribute);
1887		SyncResources(appFileInfo);
1888		CheckNoResource(file, kSupportedTypesAttribute);
1889		CHK(BMimeType(testType1).IsInstalled() == false);
1890		CHK(BMimeType(testType2).IsInstalled() == false);
1891		// set, no syncAll
1892		CHK(BMimeType(testType1).IsInstalled() == false);
1893		CHK(BMimeType(testType2).IsInstalled() == false);
1894		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_ENTRY_NOT_FOUND);
1895		// get
1896		CHK(appFileInfo.GetSupportedTypes(&types) == B_ENTRY_NOT_FOUND);
1897		CHK(appFileInfo.IsSupportedType(testType1) == false);
1898		CHK(appFileInfo.IsSupportedType(testType2) == false);
1899		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1900		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1901		CheckNoAttr(file, kSupportedTypesAttribute);
1902		SyncResources(appFileInfo);
1903		CheckNoResource(file, kSupportedTypesAttribute);
1904		CHK(BMimeType(testType1).IsInstalled() == false);
1905		CHK(BMimeType(testType2).IsInstalled() == false);
1906	}
1907	// * set supported types, remove file, create file, get supported types
1908	NextSubTest();
1909	{
1910		// clean up
1911		BMimeType(testType1).Delete();
1912		BMimeType(testType2).Delete();
1913		BMimeType(testType3).Delete();
1914		BMimeType(testType4).Delete();
1915		BMimeType(testAppSignature1).Delete();
1916		CHK(BMimeType(testAppSignature1).Install() == B_OK);
1917		CHK(BEntry(testFile1).Remove() == B_OK);
1918		// init
1919		BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE);
1920		BAppFileInfo appFileInfo;
1921		CHK(appFileInfo.SetTo(&file) == B_OK);
1922		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1923		// set
1924		CHK(appFileInfo.SetSupportedTypes(&testTypes1) == B_OK);
1925		// get
1926		BMessage types;
1927		CHK(appFileInfo.GetSupportedTypes(&types) == B_OK);
1928		CHK(SupportedTypesValue(types) == SupportedTypesValue(testTypes1));
1929		CHK(appFileInfo.IsSupportedType(testType1) == true);
1930		CHK(appFileInfo.IsSupportedType(testType2) == true);
1931		CHK(appFileInfo.Supports(&mimeTestType1) == true);
1932		CHK(appFileInfo.Supports(&mimeTestType2) == true);
1933		CheckSupportedTypesAttr(file, &testTypes1);
1934		SyncResources(appFileInfo);
1935		CheckSupportedTypesResource(file, &testTypes1);
1936		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1937		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1938		// remove the file
1939		appFileInfo.SetTo(NULL);
1940		file.Unset();
1941		CHK(BEntry(testFile1).Remove() == B_OK);
1942		// init
1943		CHK(file.SetTo(testFile1, B_READ_WRITE | B_CREATE_FILE) == B_OK);
1944		CHK(appFileInfo.SetTo(&file) == B_OK);
1945		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
1946		// get
1947		BMessage types2;
1948		CHK(appFileInfo.GetSupportedTypes(&types2) == B_ENTRY_NOT_FOUND);
1949		CHK(appFileInfo.IsSupportedType(testType1) == false);
1950		CHK(appFileInfo.IsSupportedType(testType2) == false);
1951		CHK(appFileInfo.Supports(&mimeTestType1) == false);
1952		CHK(appFileInfo.Supports(&mimeTestType2) == false);
1953		CheckNoAttr(file, kSupportedTypesAttribute);
1954		SyncResources(appFileInfo);
1955		CheckNoResource(file, kSupportedTypesAttribute);
1956		CHK(IsSupportingApp(testType1, testAppSignature1) == true);
1957		CHK(IsSupportingApp(testType2, testAppSignature1) == true);
1958	}
1959}
1960
1961// IconTest
1962void
1963AppFileInfoTest::IconTest()
1964{
1965	// status_t GetIcon(BBitmap *icon, icon_size k) const
1966	// * NULL icon => B_BAD_VALUE
1967	NextSubTest();
1968	{
1969		BFile file(testFile1, B_READ_WRITE);
1970		BAppFileInfo appFileInfo;
1971		CHK(appFileInfo.SetTo(&file) == B_OK);
1972		CHK(appFileInfo.GetIcon(NULL, B_MINI_ICON) == B_BAD_VALUE);
1973		CHK(appFileInfo.GetIcon(NULL, B_LARGE_ICON) == B_BAD_VALUE);
1974	}
1975	// * uninitialized => B_NO_INIT
1976	NextSubTest();
1977	{
1978		BAppFileInfo appFileInfo;
1979		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
1980		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_NO_INIT);
1981		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
1982		CHK(appFileInfo.GetIcon(&icon2, B_LARGE_ICON) == B_NO_INIT);
1983	}
1984	// * icon dimensions != icon size => B_BAD_VALUE
1985	NextSubTest();
1986	{
1987		BFile file(testFile1, B_READ_WRITE);
1988		BAppFileInfo appFileInfo;
1989		CHK(appFileInfo.SetTo(&file) == B_OK);
1990		BBitmap icon(BRect(0, 0, 31, 31), B_CMAP8);
1991		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_BAD_VALUE);
1992		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
1993		CHK(appFileInfo.GetIcon(&icon2, B_LARGE_ICON) == B_BAD_VALUE);
1994	}
1995	// * has no icon => B_ENTRY_NOT_FOUND
1996	NextSubTest();
1997	{
1998		BFile file(testFile1, B_READ_WRITE);
1999		BAppFileInfo appFileInfo;
2000		CHK(appFileInfo.SetTo(&file) == B_OK);
2001		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2002		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_ENTRY_NOT_FOUND);
2003	}
2004	// * set, get, reset, get
2005	NextSubTest();
2006	{
2007		BFile file(testFile1, B_READ_WRITE);
2008		BAppFileInfo appFileInfo;
2009		CHK(appFileInfo.SetTo(&file) == B_OK);
2010		// mini
2011		// set
2012		CHK(appFileInfo.SetIcon(fIconM1, B_MINI_ICON) == B_OK);
2013		// get
2014		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2015		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_OK);
2016		CHK(icon_equal(fIconM1, &icon));
2017		CheckIconAttr(file, fIconM1);
2018		SyncResources(appFileInfo);
2019		CheckIconResource(file, fIconM1);
2020		// reset
2021		CHK(appFileInfo.SetIcon(fIconM2, B_MINI_ICON) == B_OK);
2022		// get
2023		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
2024		CHK(appFileInfo.GetIcon(&icon2, B_MINI_ICON) == B_OK);
2025		CHK(icon_equal(fIconM2, &icon2));
2026		CheckIconAttr(file, fIconM2);
2027		SyncResources(appFileInfo);
2028		CheckIconResource(file, fIconM2);
2029		// large
2030		// set
2031		CHK(appFileInfo.SetIcon(fIconL1, B_LARGE_ICON) == B_OK);
2032		// get
2033		BBitmap icon3(BRect(0, 0, 31, 31), B_CMAP8);
2034		CHK(appFileInfo.GetIcon(&icon3, B_LARGE_ICON) == B_OK);
2035		CHK(icon_equal(fIconL1, &icon3));
2036		CheckIconAttr(file, fIconL1);
2037		SyncResources(appFileInfo);
2038		CheckIconResource(file, fIconL1);
2039		// reset
2040		CHK(appFileInfo.SetIcon(fIconL2, B_LARGE_ICON) == B_OK);
2041		// get
2042		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2043		CHK(appFileInfo.GetIcon(&icon4, B_LARGE_ICON) == B_OK);
2044		CHK(icon_equal(fIconL2, &icon4));
2045		CheckIconAttr(file, fIconL2);
2046		SyncResources(appFileInfo);
2047		CheckIconResource(file, fIconL2);
2048	}
2049	// * bitmap color_space != B_CMAP8 => B_OK
2050	NextSubTest();
2051	{
2052		BFile file(testFile1, B_READ_WRITE);
2053		BAppFileInfo appFileInfo;
2054		CHK(appFileInfo.SetTo(&file) == B_OK);
2055		// mini
2056		BBitmap icon(BRect(0, 0, 15, 15), B_RGB32);
2057		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_OK);
2058		BBitmap icon2(BRect(0, 0, 15, 15), B_RGB32);
2059		// SetBits() can be used, since there's no row padding for 16x16.
2060		icon2.SetBits(fIconM2->Bits(), fIconM2->BitsLength(), 0, B_CMAP8);
2061		CHK(icon_equal(&icon, &icon2));
2062		// large
2063// R5: Crashes for some weird reason in GetIcon().
2064#ifndef TEST_R5
2065		BBitmap icon3(BRect(0, 0, 31, 31), B_RGB32);
2066		CHK(appFileInfo.GetIcon(&icon3, B_LARGE_ICON) == B_OK);
2067		BBitmap icon4(BRect(0, 0, 31, 31), B_RGB32);
2068		// SetBits() can be used, since there's no row padding for 32x32.
2069		icon4.SetBits(fIconL2->Bits(), fIconL2->BitsLength(), 0, B_CMAP8);
2070		CHK(icon_equal(&icon3, &icon4));
2071#endif
2072	}
2073
2074	// status_t SetIcon(const BBitmap *icon, icon_size k)
2075	// * NULL icon => unsets icon, B_OK
2076	NextSubTest();
2077	{
2078		BFile file(testFile1, B_READ_WRITE);
2079		BAppFileInfo appFileInfo;
2080		CHK(appFileInfo.SetTo(&file) == B_OK);
2081		// mini
2082		// set
2083		CHK(appFileInfo.SetIcon(NULL, B_MINI_ICON) == B_OK);
2084		// get
2085		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2086		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_ENTRY_NOT_FOUND);
2087		CheckNoAttr(file, kMiniIconAttribute);
2088		SyncResources(appFileInfo);
2089		CheckNoResource(file, kMiniIconAttribute);
2090		// large
2091		// set
2092		CHK(appFileInfo.SetIcon(NULL, B_LARGE_ICON) == B_OK);
2093		// get
2094		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2095		CHK(appFileInfo.GetIcon(&icon2, B_LARGE_ICON) == B_ENTRY_NOT_FOUND);
2096		CheckNoAttr(file, kLargeIconAttribute);
2097		SyncResources(appFileInfo);
2098		CheckNoResource(file, kLargeIconAttribute);
2099	}
2100	// * uninitialized => B_NO_INIT
2101	NextSubTest();
2102	{
2103		BAppFileInfo appFileInfo;
2104		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2105		CHK(appFileInfo.SetIcon(&icon, B_MINI_ICON) == B_NO_INIT);
2106		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2107		CHK(appFileInfo.SetIcon(&icon2, B_LARGE_ICON) == B_NO_INIT);
2108	}
2109	// * icon dimensions != icon size => B_BAD_VALUE
2110	NextSubTest();
2111	{
2112		BFile file(testFile1, B_READ_WRITE);
2113		BAppFileInfo appFileInfo;
2114		CHK(appFileInfo.SetTo(&file) == B_OK);
2115		BBitmap icon(BRect(0, 0, 31, 31), B_CMAP8);
2116		CHK(appFileInfo.SetIcon(&icon, B_MINI_ICON) == B_BAD_VALUE);
2117		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
2118		CHK(appFileInfo.SetIcon(&icon2, B_LARGE_ICON) == B_BAD_VALUE);
2119	}
2120	// * file has app signature, set an icon => the icon is also set on the
2121	//   MIME type
2122	NextSubTest();
2123	{
2124		BFile file(testFile1, B_READ_WRITE);
2125		BAppFileInfo appFileInfo;
2126		CHK(appFileInfo.SetTo(&file) == B_OK);
2127		// uninstalled signature
2128		BMimeType mimeType(testAppSignature1);
2129		CHK(mimeType.IsInstalled() == false);
2130		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
2131		CHK(appFileInfo.SetIcon(fIconM1, B_MINI_ICON) == B_OK);
2132		CHK(appFileInfo.SetIcon(fIconL1, B_LARGE_ICON) == B_OK);
2133		CHK(mimeType.IsInstalled() == true);
2134		// get mini
2135		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2136		CHK(mimeType.GetIcon(&icon, B_MINI_ICON) == B_OK);
2137		CHK(icon_equal(fIconM1, &icon));
2138		// get large
2139		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2140		CHK(mimeType.GetIcon(&icon2, B_LARGE_ICON) == B_OK);
2141		CHK(icon_equal(fIconL1, &icon2));
2142		// installed signature
2143		CHK(appFileInfo.SetIcon(fIconM2, B_MINI_ICON) == B_OK);
2144		CHK(appFileInfo.SetIcon(fIconL2, B_LARGE_ICON) == B_OK);
2145		// get mini
2146		BBitmap icon3(BRect(0, 0, 15, 15), B_CMAP8);
2147		CHK(mimeType.GetIcon(&icon3, B_MINI_ICON) == B_OK);
2148		CHK(icon_equal(fIconM2, &icon3));
2149		// get large
2150		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2151		CHK(mimeType.GetIcon(&icon4, B_LARGE_ICON) == B_OK);
2152		CHK(icon_equal(fIconL2, &icon4));
2153	}
2154}
2155
2156// VersionInfoTest
2157void
2158AppFileInfoTest::VersionInfoTest()
2159{
2160//	status_t GetVersionInfo(version_info *info, version_kind kind) const;
2161//	status_t SetVersionInfo(const version_info *info, version_kind kind);
2162	version_info testInfo1 = { 1, 1, 1, 1, 1, "short1", "long1" };
2163	version_info testInfo2 = { 2, 2, 2, 2, 2, "short2", "long2" };
2164	version_info testInfo3 = { 3, 3, 3, 3, 3, "short3", "long3" };
2165	version_info testInfo4 = { 4, 4, 4, 4, 4, "short4", "long4" };
2166
2167
2168	// status_t GetVersionInfo(version_info *info, version_kind kind) const
2169	// * uninitialized => B_NO_INIT
2170	NextSubTest();
2171	{
2172		BAppFileInfo appFileInfo;
2173		version_info info;
2174		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND)
2175			== B_NO_INIT);
2176		version_info info2;
2177		CHK(appFileInfo.GetVersionInfo(&info2, B_SYSTEM_VERSION_KIND)
2178			== B_NO_INIT);
2179	}
2180	// * has no version info => B_ENTRY_NOT_FOUND
2181	NextSubTest();
2182	{
2183		BFile file(testFile1, B_READ_WRITE);
2184		BAppFileInfo appFileInfo;
2185		CHK(appFileInfo.SetTo(&file) == B_OK);
2186		version_info info;
2187		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND)
2188			== B_ENTRY_NOT_FOUND);
2189		version_info info2;
2190		CHK(appFileInfo.GetVersionInfo(&info2, B_SYSTEM_VERSION_KIND)
2191			== B_ENTRY_NOT_FOUND);
2192	}
2193	// * set, get, reset, get
2194	NextSubTest();
2195	{
2196		BFile file(testFile1, B_READ_WRITE);
2197		BAppFileInfo appFileInfo;
2198		CHK(appFileInfo.SetTo(&file) == B_OK);
2199		// set app info
2200		CHK(appFileInfo.SetVersionInfo(&testInfo1, B_APP_VERSION_KIND)
2201			== B_OK);
2202		// get both infos
2203		version_info info;
2204		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND) == B_OK);
2205		CHK(info == testInfo1);
2206		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) == B_OK);
2207		// set app info
2208		CHK(appFileInfo.SetVersionInfo(&testInfo2, B_SYSTEM_VERSION_KIND)
2209			== B_OK);
2210		// get
2211		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND) == B_OK);
2212		CHK(info == testInfo1);
2213		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) == B_OK);
2214		CHK(info == testInfo2);
2215		version_info testInfos1[] = { testInfo1, testInfo2 };
2216		CheckVersionInfoAttr(file, testInfos1);
2217		SyncResources(appFileInfo);
2218		CheckVersionInfoResource(file, testInfos1);
2219		// reset app info
2220		CHK(appFileInfo.SetVersionInfo(&testInfo3, B_APP_VERSION_KIND)
2221			== B_OK);
2222		// get
2223		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND) == B_OK);
2224		CHK(info == testInfo3);
2225		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) == B_OK);
2226		CHK(info == testInfo2);
2227		version_info testInfos2[] = { testInfo3, testInfo2 };
2228		CheckVersionInfoAttr(file, testInfos2);
2229		SyncResources(appFileInfo);
2230		CheckVersionInfoResource(file, testInfos2);
2231		// reset system info
2232		CHK(appFileInfo.SetVersionInfo(&testInfo4, B_SYSTEM_VERSION_KIND)
2233			== B_OK);
2234		// get
2235		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND) == B_OK);
2236		CHK(info == testInfo3);
2237		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) == B_OK);
2238		CHK(info == testInfo4);
2239		version_info testInfos3[] = { testInfo3, testInfo4 };
2240		CheckVersionInfoAttr(file, testInfos3);
2241		SyncResources(appFileInfo);
2242		CheckVersionInfoResource(file, testInfos3);
2243	}
2244	// * NULL info => B_BAD_VALUE
2245// R5: crashes when passing a NULL version_info
2246#ifndef TEST_R5
2247	NextSubTest();
2248	{
2249		BFile file(testFile1, B_READ_WRITE);
2250		BAppFileInfo appFileInfo;
2251		CHK(appFileInfo.SetTo(&file) == B_OK);
2252		CHK(equals(appFileInfo.GetVersionInfo(NULL, B_APP_VERSION_KIND),
2253				   B_BAD_ADDRESS, B_BAD_VALUE));
2254		CHK(equals(appFileInfo.GetVersionInfo(NULL, B_SYSTEM_VERSION_KIND),
2255				   B_BAD_ADDRESS, B_BAD_VALUE));
2256	}
2257#endif
2258
2259	// status_t SetVersionInfo(const version_info *info, version_kind kind)
2260	// * NULL info => unsets both infos, B_OK
2261// R5: crashes when passing a NULL version_info
2262#ifndef TEST_R5
2263	NextSubTest();
2264	{
2265		BFile file(testFile1, B_READ_WRITE);
2266		BAppFileInfo appFileInfo;
2267		CHK(appFileInfo.SetTo(&file) == B_OK);
2268		// unset app info
2269		CHK(appFileInfo.SetVersionInfo(NULL, B_APP_VERSION_KIND)
2270			== B_OK);
2271		// try to get
2272		version_info info;
2273		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND)
2274			== B_ENTRY_NOT_FOUND);
2275		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND)
2276			== B_ENTRY_NOT_FOUND);
2277		// check
2278		CheckNoAttr(file, kVersionInfoAttribute);
2279		SyncResources(appFileInfo);
2280		CheckNoResource(file, kVersionInfoAttribute);
2281		// reset the infos
2282		CHK(appFileInfo.SetVersionInfo(&testInfo1, B_APP_VERSION_KIND)
2283			== B_OK);
2284		CHK(appFileInfo.SetVersionInfo(&testInfo1, B_SYSTEM_VERSION_KIND)
2285			== B_OK);
2286		// unset system info
2287		CHK(appFileInfo.SetVersionInfo(NULL, B_SYSTEM_VERSION_KIND) == B_OK);
2288		// try to get
2289		CHK(appFileInfo.GetVersionInfo(&info, B_APP_VERSION_KIND)
2290			== B_ENTRY_NOT_FOUND);
2291		CHK(appFileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND)
2292			== B_ENTRY_NOT_FOUND);
2293		// check
2294		CheckNoAttr(file, kVersionInfoAttribute);
2295		SyncResources(appFileInfo);
2296		CheckNoResource(file, kVersionInfoAttribute);
2297	}
2298#endif
2299	// * uninitialized => B_NO_INIT
2300	NextSubTest();
2301	{
2302		BAppFileInfo appFileInfo;
2303		CHK(appFileInfo.SetVersionInfo(&testInfo1, B_APP_VERSION_KIND)
2304			== B_NO_INIT);
2305		CHK(appFileInfo.GetVersionInfo(&testInfo1, B_SYSTEM_VERSION_KIND)
2306			== B_NO_INIT);
2307	}
2308}
2309
2310// IconForTypeTest
2311void
2312AppFileInfoTest::IconForTypeTest()
2313{
2314	// status_t GetIconForType(const char *type, BBitmap *icon,
2315	//						   icon_size which) const
2316	// * NULL icon => B_BAD_VALUE
2317	NextSubTest();
2318	{
2319		BFile file(testFile1, B_READ_WRITE);
2320		BAppFileInfo appFileInfo;
2321		CHK(appFileInfo.SetTo(&file) == B_OK);
2322		CHK(appFileInfo.GetIconForType(testType1, NULL, B_MINI_ICON)
2323			== B_BAD_VALUE);
2324		CHK(appFileInfo.GetIconForType(testType1, NULL, B_LARGE_ICON)
2325			== B_BAD_VALUE);
2326	}
2327	// * uninitialized => B_NO_INIT
2328	NextSubTest();
2329	{
2330		BAppFileInfo appFileInfo;
2331		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2332		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON)
2333			== B_NO_INIT);
2334		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2335		CHK(appFileInfo.GetIconForType(testType1, &icon2, B_LARGE_ICON)
2336			== B_NO_INIT);
2337	}
2338	// * icon dimensions != icon size => B_BAD_VALUE
2339	NextSubTest();
2340	{
2341		BFile file(testFile1, B_READ_WRITE);
2342		BAppFileInfo appFileInfo;
2343		CHK(appFileInfo.SetTo(&file) == B_OK);
2344		BBitmap icon(BRect(0, 0, 31, 31), B_CMAP8);
2345		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON)
2346			== B_BAD_VALUE);
2347		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
2348		CHK(appFileInfo.GetIconForType(testType1, &icon2, B_LARGE_ICON)
2349			== B_BAD_VALUE);
2350	}
2351	// * has no icon => B_ENTRY_NOT_FOUND
2352	NextSubTest();
2353	{
2354		BFile file(testFile1, B_READ_WRITE);
2355		BAppFileInfo appFileInfo;
2356		CHK(appFileInfo.SetTo(&file) == B_OK);
2357		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2358		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON)
2359			== B_ENTRY_NOT_FOUND);
2360	}
2361	// * set, get, reset, get
2362	NextSubTest();
2363	{
2364		BFile file(testFile1, B_READ_WRITE);
2365		BAppFileInfo appFileInfo;
2366		CHK(appFileInfo.SetTo(&file) == B_OK);
2367		// mini
2368		// set
2369		CHK(appFileInfo.SetIconForType(testType1, fIconM1, B_MINI_ICON)
2370			== B_OK);
2371		// get
2372		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2373		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON) == B_OK);
2374		CHK(icon_equal(fIconM1, &icon));
2375		CheckIconForTypeAttr(file, testType1, fIconM1);
2376		SyncResources(appFileInfo);
2377		CheckIconForTypeResource(file, testType1, fIconM1);
2378		// reset
2379		CHK(appFileInfo.SetIconForType(testType1, fIconM2, B_MINI_ICON)
2380			== B_OK);
2381		// get
2382		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
2383		CHK(appFileInfo.GetIconForType(testType1, &icon2, B_MINI_ICON)
2384			== B_OK);
2385		CHK(icon_equal(fIconM2, &icon2));
2386		CheckIconForTypeAttr(file, testType1, fIconM2);
2387		SyncResources(appFileInfo);
2388		CheckIconForTypeResource(file, testType1, fIconM2);
2389		// large
2390		// set
2391		CHK(appFileInfo.SetIconForType(testType1, fIconL1, B_LARGE_ICON)
2392			== B_OK);
2393		// get
2394		BBitmap icon3(BRect(0, 0, 31, 31), B_CMAP8);
2395		CHK(appFileInfo.GetIconForType(testType1, &icon3, B_LARGE_ICON)
2396			== B_OK);
2397		CHK(icon_equal(fIconL1, &icon3));
2398		CheckIconForTypeAttr(file, testType1, fIconL1);
2399		SyncResources(appFileInfo);
2400		CheckIconForTypeResource(file, testType1, fIconL1);
2401		// reset
2402		CHK(appFileInfo.SetIconForType(testType1, fIconL2, B_LARGE_ICON)
2403			== B_OK);
2404		// get
2405		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2406		CHK(appFileInfo.GetIconForType(testType1, &icon4, B_LARGE_ICON)
2407			== B_OK);
2408		CHK(icon_equal(fIconL2, &icon4));
2409		CheckIconForTypeAttr(file, testType1, fIconL2);
2410		SyncResources(appFileInfo);
2411		CheckIconForTypeResource(file, testType1, fIconL2);
2412	}
2413	// * bitmap color_space != B_CMAP8 => B_OK
2414	NextSubTest();
2415	{
2416		BFile file(testFile1, B_READ_WRITE);
2417		BAppFileInfo appFileInfo;
2418		CHK(appFileInfo.SetTo(&file) == B_OK);
2419		// mini
2420		BBitmap icon(BRect(0, 0, 15, 15), B_RGB32);
2421		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON) == B_OK);
2422		BBitmap icon2(BRect(0, 0, 15, 15), B_RGB32);
2423		// SetBits() can be used, since there's no row padding for 16x16.
2424		icon2.SetBits(fIconM2->Bits(), fIconM2->BitsLength(), 0, B_CMAP8);
2425		CHK(icon_equal(&icon, &icon2));
2426		// large
2427// R5: Crashes for some weird reason in GetIconForType().
2428#ifndef TEST_R5
2429		BBitmap icon3(BRect(0, 0, 31, 31), B_RGB32);
2430		CHK(appFileInfo.GetIconForType(testType1, &icon3, B_LARGE_ICON)
2431			== B_OK);
2432		BBitmap icon4(BRect(0, 0, 31, 31), B_RGB32);
2433		// SetBits() can be used, since there's no row padding for 32x32.
2434		icon4.SetBits(fIconL2->Bits(), fIconL2->BitsLength(), 0, B_CMAP8);
2435		CHK(icon_equal(&icon3, &icon4));
2436#endif
2437	}
2438
2439	// status_t SetIconForType(const char *type, const BBitmap *icon,
2440	//						   icon_size which)
2441	// * NULL icon => unsets icon, B_OK
2442	NextSubTest();
2443	{
2444		BFile file(testFile1, B_READ_WRITE);
2445		BAppFileInfo appFileInfo;
2446		CHK(appFileInfo.SetTo(&file) == B_OK);
2447		// mini
2448		// set
2449		CHK(appFileInfo.SetIconForType(testType1, NULL, B_MINI_ICON) == B_OK);
2450		// get
2451		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2452		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON)
2453			== B_ENTRY_NOT_FOUND);
2454		CheckNoIconForTypeAttr(file, testType1, B_MINI_ICON);
2455		SyncResources(appFileInfo);
2456		CheckNoIconForTypeResource(file, testType1, B_MINI_ICON);
2457		// large
2458		// set
2459		CHK(appFileInfo.SetIconForType(testType1, NULL, B_LARGE_ICON) == B_OK);
2460		// get
2461		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2462		CHK(appFileInfo.GetIconForType(testType1, &icon2, B_LARGE_ICON)
2463			== B_ENTRY_NOT_FOUND);
2464		CheckNoIconForTypeAttr(file, testType1, B_LARGE_ICON);
2465		SyncResources(appFileInfo);
2466		CheckNoIconForTypeResource(file, testType1, B_LARGE_ICON);
2467	}
2468	// * uninitialized => B_NO_INIT
2469	NextSubTest();
2470	{
2471		BAppFileInfo appFileInfo;
2472		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2473		CHK(appFileInfo.SetIconForType(testType1, &icon, B_MINI_ICON)
2474			== B_NO_INIT);
2475		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2476		CHK(appFileInfo.SetIconForType(testType1, &icon2, B_LARGE_ICON)
2477			== B_NO_INIT);
2478	}
2479	// * icon dimensions != icon size => B_BAD_VALUE
2480	NextSubTest();
2481	{
2482		BFile file(testFile1, B_READ_WRITE);
2483		BAppFileInfo appFileInfo;
2484		CHK(appFileInfo.SetTo(&file) == B_OK);
2485		BBitmap icon(BRect(0, 0, 31, 31), B_CMAP8);
2486		CHK(appFileInfo.SetIconForType(testType1, &icon, B_MINI_ICON)
2487			== B_BAD_VALUE);
2488		BBitmap icon2(BRect(0, 0, 15, 15), B_CMAP8);
2489		CHK(appFileInfo.SetIconForType(testType1, &icon2, B_LARGE_ICON)
2490			== B_BAD_VALUE);
2491	}
2492	// * NULL type => set standard icon
2493	NextSubTest();
2494	{
2495		BFile file(testFile1, B_READ_WRITE);
2496		BAppFileInfo appFileInfo;
2497		CHK(appFileInfo.SetTo(&file) == B_OK);
2498		CHK(appFileInfo.SetIconForType(NULL, fIconM1, B_MINI_ICON) == B_OK);
2499		CHK(appFileInfo.SetIconForType(NULL, fIconL1, B_LARGE_ICON) == B_OK);
2500		// get mini icon via GetIcon()
2501		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2502		CHK(appFileInfo.GetIcon(&icon, B_MINI_ICON) == B_OK);
2503		CHK(icon_equal(fIconM1, &icon));
2504		CheckIconAttr(file, fIconM1);
2505		SyncResources(appFileInfo);
2506		CheckIconResource(file, fIconM1);
2507		// get large via GetIcon()
2508		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2509		CHK(appFileInfo.GetIcon(&icon2, B_LARGE_ICON) == B_OK);
2510		CHK(icon_equal(fIconL1, &icon2));
2511		CheckIconAttr(file, fIconL1);
2512		SyncResources(appFileInfo);
2513		CheckIconResource(file, fIconL1);
2514		// get mini icon via GetIconForType()
2515		BBitmap icon3(BRect(0, 0, 15, 15), B_CMAP8);
2516		CHK(appFileInfo.GetIconForType(NULL, &icon3, B_MINI_ICON) == B_OK);
2517		CHK(icon_equal(fIconM1, &icon3));
2518		CheckIconAttr(file, fIconM1);
2519		SyncResources(appFileInfo);
2520		CheckIconResource(file, fIconM1);
2521		// get large via GetIconForType()
2522		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2523		CHK(appFileInfo.GetIconForType(NULL, &icon4, B_LARGE_ICON) == B_OK);
2524		CHK(icon_equal(fIconL1, &icon4));
2525		CheckIconAttr(file, fIconL1);
2526		SyncResources(appFileInfo);
2527		CheckIconResource(file, fIconL1);
2528	}
2529	// * set icons for two types
2530	NextSubTest();
2531	{
2532		BFile file(testFile1, B_READ_WRITE);
2533		BAppFileInfo appFileInfo;
2534		CHK(appFileInfo.SetTo(&file) == B_OK);
2535		// set icons for both types
2536		CHK(appFileInfo.SetIconForType(testType1, fIconM1, B_MINI_ICON)
2537			== B_OK);
2538		CHK(appFileInfo.SetIconForType(testType1, fIconL1, B_LARGE_ICON)
2539			== B_OK);
2540		CHK(appFileInfo.SetIconForType(testType2, fIconM2, B_MINI_ICON)
2541			== B_OK);
2542		CHK(appFileInfo.SetIconForType(testType2, fIconL2, B_LARGE_ICON)
2543			== B_OK);
2544		// check first type
2545		// get mini
2546		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2547		CHK(appFileInfo.GetIconForType(testType1, &icon, B_MINI_ICON)
2548			== B_OK);
2549		CHK(icon_equal(fIconM1, &icon));
2550		CheckIconForTypeAttr(file, testType1, fIconM1);
2551		SyncResources(appFileInfo);
2552		CheckIconForTypeResource(file, testType1, fIconM1);
2553		// get large
2554		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2555		CHK(appFileInfo.GetIconForType(testType1, &icon2, B_LARGE_ICON)
2556			== B_OK);
2557		CHK(icon_equal(fIconL1, &icon2));
2558		CheckIconForTypeAttr(file, testType1, fIconL1);
2559		SyncResources(appFileInfo);
2560		CheckIconForTypeResource(file, testType1, fIconL1);
2561		// check second type
2562		// get mini
2563		BBitmap icon3(BRect(0, 0, 15, 15), B_CMAP8);
2564		CHK(appFileInfo.GetIconForType(testType2, &icon3, B_MINI_ICON)
2565			== B_OK);
2566		CHK(icon_equal(fIconM2, &icon3));
2567		CheckIconForTypeAttr(file, testType2, fIconM2);
2568		SyncResources(appFileInfo);
2569		CheckIconForTypeResource(file, testType2, fIconM2,
2570								 kMiniIconForTypeResourceID + 1);
2571		// get large
2572		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2573		CHK(appFileInfo.GetIconForType(testType2, &icon4, B_LARGE_ICON)
2574			== B_OK);
2575		CHK(icon_equal(fIconL2, &icon4));
2576		CheckIconForTypeAttr(file, testType2, fIconL2);
2577		SyncResources(appFileInfo);
2578		CheckIconForTypeResource(file, testType2, fIconL2,
2579								 kLargeIconForTypeResourceID + 1);
2580		// unset both icons
2581		CHK(appFileInfo.SetIconForType(testType1, NULL, B_MINI_ICON) == B_OK);
2582		CHK(appFileInfo.SetIconForType(testType1, NULL, B_LARGE_ICON) == B_OK);
2583		CHK(appFileInfo.SetIconForType(testType2, NULL, B_MINI_ICON) == B_OK);
2584		CHK(appFileInfo.SetIconForType(testType2, NULL, B_LARGE_ICON) == B_OK);
2585	}
2586	// * invalid type => B_OK
2587	NextSubTest();
2588	{
2589		BFile file(testFile1, B_READ_WRITE);
2590		BAppFileInfo appFileInfo;
2591		CHK(appFileInfo.SetTo(&file) == B_OK);
2592		CHK(appFileInfo.SetIconForType(invalidTestType, fIconM1, B_MINI_ICON)
2593			== B_BAD_VALUE);
2594		CHK(appFileInfo.SetIconForType(invalidTestType, fIconL1, B_LARGE_ICON)
2595			== B_BAD_VALUE);
2596		// get mini
2597		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2598		CHK(appFileInfo.GetIconForType(invalidTestType, &icon, B_MINI_ICON)
2599			== B_BAD_VALUE);
2600		CheckNoIconForTypeAttr(file, invalidTestType, B_LARGE_ICON);
2601		CheckNoIconForTypeResource(file, invalidTestType, B_LARGE_ICON);
2602		// get large
2603		BBitmap icon3(BRect(0, 0, 31, 31), B_CMAP8);
2604		CHK(appFileInfo.GetIconForType(invalidTestType, &icon3, B_LARGE_ICON)
2605			== B_BAD_VALUE);
2606		CheckNoIconForTypeAttr(file, invalidTestType, B_MINI_ICON);
2607		CheckNoIconForTypeResource(file, invalidTestType, B_MINI_ICON);
2608	}
2609	// * too long type => B_BAD_VALUE
2610	NextSubTest();
2611	{
2612		BFile file(testFile1, B_READ_WRITE);
2613		BAppFileInfo appFileInfo;
2614		CHK(appFileInfo.SetTo(&file) == B_OK);
2615		CHK(appFileInfo.SetIconForType(tooLongTestType, fIconM1, B_MINI_ICON)
2616			== B_BAD_VALUE);
2617		CHK(appFileInfo.SetIconForType(tooLongTestType, fIconL1, B_LARGE_ICON)
2618			== B_BAD_VALUE);
2619	}
2620	// * file has app signature, set an icon => the icon is also set on the
2621	//   MIME type
2622	NextSubTest();
2623	{
2624		BFile file(testFile1, B_READ_WRITE);
2625		BAppFileInfo appFileInfo;
2626		CHK(appFileInfo.SetTo(&file) == B_OK);
2627		// uninstalled signature
2628		BMimeType mimeType(testAppSignature1);
2629		CHK(mimeType.IsInstalled() == false);
2630		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
2631		CHK(appFileInfo.SetIconForType(testType1, fIconM1, B_MINI_ICON)
2632			== B_OK);
2633		CHK(appFileInfo.SetIconForType(testType1, fIconL1, B_LARGE_ICON)
2634			== B_OK);
2635		CHK(mimeType.IsInstalled() == true);
2636		CHK(BMimeType(testType1).IsInstalled() == false);
2637		// get mini
2638		BBitmap icon(BRect(0, 0, 15, 15), B_CMAP8);
2639		CHK(mimeType.GetIconForType(testType1, &icon, B_MINI_ICON)
2640			== B_OK);
2641		CHK(icon_equal(fIconM1, &icon));
2642		// get large
2643		BBitmap icon2(BRect(0, 0, 31, 31), B_CMAP8);
2644		CHK(mimeType.GetIconForType(testType1, &icon2, B_LARGE_ICON)
2645			== B_OK);
2646		CHK(icon_equal(fIconL1, &icon2));
2647		// installed signature
2648		CHK(appFileInfo.SetIconForType(testType1, fIconM2, B_MINI_ICON)
2649			== B_OK);
2650		CHK(appFileInfo.SetIconForType(testType1, fIconL2, B_LARGE_ICON)
2651			== B_OK);
2652		// get mini
2653		BBitmap icon3(BRect(0, 0, 15, 15), B_CMAP8);
2654		CHK(mimeType.GetIconForType(testType1, &icon3, B_MINI_ICON)
2655			== B_OK);
2656		CHK(icon_equal(fIconM2, &icon3));
2657		// get large
2658		BBitmap icon4(BRect(0, 0, 31, 31), B_CMAP8);
2659		CHK(mimeType.GetIconForType(testType1, &icon4, B_LARGE_ICON)
2660			== B_OK);
2661		CHK(icon_equal(fIconL2, &icon4));
2662	}
2663}
2664
2665
2666// InfoLocationTester
2667template<typename Value, typename Setter, typename Getter, typename Checker>
2668static
2669void
2670InfoLocationTester(const Value &testValue1, const Value &testValue2,
2671				   const Value &testValue3)
2672{
2673	BFile file(testFile1, B_READ_WRITE);
2674	BAppFileInfo appFileInfo;
2675	CHK(appFileInfo.SetTo(&file) == B_OK);
2676	CHK(appFileInfo.InitCheck() == B_OK);
2677	CHK(appFileInfo.IsUsingAttributes() == true);
2678	CHK(appFileInfo.IsUsingResources() == true);
2679	// set value
2680	CHK(Setter::Set(appFileInfo, testValue1) == B_OK);
2681	CHK(appFileInfo.IsUsingAttributes() == true);
2682	CHK(appFileInfo.IsUsingResources() == true);
2683	// force resources synchronization
2684	SyncResources(appFileInfo);
2685	// get value
2686	Value value;
2687	CHK(Getter::Get(appFileInfo, value) == B_OK);
2688	CHK(value == testValue1);
2689	// check attribute/resource
2690	Checker::CheckAttribute(file, testValue1);
2691	Checker::CheckResource(file, testValue1);
2692	// set on B_USE_ATTRIBUTES
2693	appFileInfo.SetInfoLocation(B_USE_ATTRIBUTES);
2694	CHK(appFileInfo.IsUsingAttributes() == true);
2695	CHK(appFileInfo.IsUsingResources() == false);
2696	// set value
2697	CHK(Setter::Set(appFileInfo, testValue2) == B_OK);
2698	// force resources synchronization
2699	SyncResources(appFileInfo);
2700	// get value
2701	Value value1;
2702	CHK(Getter::Get(appFileInfo, value1) == B_OK);
2703	CHK(value1 == testValue2);
2704	// check attribute/resource -- resource should be old
2705	Checker::CheckAttribute(file, testValue2);
2706	Checker::CheckResource(file, testValue1);
2707	// set on B_USE_BOTH_LOCATIONS
2708	appFileInfo.SetInfoLocation(B_USE_BOTH_LOCATIONS);
2709	CHK(appFileInfo.IsUsingAttributes() == true);
2710	CHK(appFileInfo.IsUsingResources() == true);
2711	// get value -- the attribute is preferred
2712	Value value2;
2713	CHK(Getter::Get(appFileInfo, value2) == B_OK);
2714	CHK(value2 == testValue2);
2715	// set on B_USE_RESOURCES
2716	appFileInfo.SetInfoLocation(B_USE_RESOURCES);
2717	CHK(appFileInfo.IsUsingAttributes() == false);
2718	CHK(appFileInfo.IsUsingResources() == true);
2719	// set value
2720	CHK(Setter::Set(appFileInfo, testValue3) == B_OK);
2721	// force resources synchronization
2722	SyncResources(appFileInfo);
2723	// get value
2724	Value value3;
2725	CHK(Getter::Get(appFileInfo, value3) == B_OK);
2726	CHK(value3 == testValue3);
2727	// check attribute/resource -- attribute should be old
2728	Checker::CheckAttribute(file, testValue2);
2729	Checker::CheckResource(file, testValue3);
2730}
2731
2732// InfoLocationTest
2733void
2734AppFileInfoTest::InfoLocationTest()
2735{
2736	// tests:
2737	// * void SetInfoLocation(info_location location);
2738	// * bool IsUsingAttributes() const;
2739	// * bool IsUsingResources() const;
2740
2741	// type
2742	NextSubTest();
2743	InfoLocationTester<TypeValue, TypeSetter, TypeGetter, TypeChecker>(
2744		TypeValue(testType1), TypeValue(testType2), TypeValue(testType3));
2745
2746	// signature
2747	NextSubTest();
2748	InfoLocationTester<SignatureValue, SignatureSetter, SignatureGetter,
2749					   SignatureChecker>(
2750		SignatureValue(testAppSignature1), SignatureValue(testAppSignature2),
2751		SignatureValue(testAppSignature3));
2752
2753	// app flags
2754	NextSubTest();
2755	InfoLocationTester<AppFlagsValue, AppFlagsSetter, AppFlagsGetter,
2756					   AppFlagsChecker>(
2757		AppFlagsValue(B_SINGLE_LAUNCH | B_ARGV_ONLY),
2758		AppFlagsValue(B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP),
2759		AppFlagsValue(B_MULTIPLE_LAUNCH));
2760
2761	// supported types
2762	NextSubTest();
2763	// The file needs to have a signature and the signature must be known
2764	// to the MIME database. Otherwise SetSupportedType() fails.
2765	{
2766		BFile file(testFile1, B_READ_WRITE);
2767		BAppFileInfo appFileInfo;
2768		CHK(appFileInfo.SetTo(&file) == B_OK);
2769		CHK(appFileInfo.SetSignature(testAppSignature1) == B_OK);
2770		BMimeType type(testAppSignature1);
2771		if (!type.IsInstalled())
2772			CHK(type.Install() == B_OK);
2773	}
2774	const char *supportedTypes1[] = { testType1 };
2775	const char *supportedTypes2[] = { testType2, testType3 };
2776	const char *supportedTypes3[] = { testType3, testType2, testType1 };
2777	InfoLocationTester<SupportedTypesValue, SupportedTypesSetter,
2778					   SupportedTypesGetter, SupportedTypesChecker>(
2779		SupportedTypesValue(supportedTypes1, 1),
2780		SupportedTypesValue(supportedTypes2, 2),
2781		SupportedTypesValue(supportedTypes3, 3));
2782
2783	// icon
2784	NextSubTest();
2785	InfoLocationTester<IconValue, IconSetter, IconGetter, IconChecker>(
2786		IconValue(fIconM1, fIconL1),
2787		IconValue(fIconM2, fIconL2),
2788		IconValue(fIconM3, fIconL3));
2789
2790	// version info
2791	NextSubTest();
2792	version_info versionInfo1 = { 1, 1, 1, 1, 1, "short1", "long1" };
2793	version_info versionInfo2 = { 2, 2, 2, 2, 2, "short2", "long2" };
2794	version_info versionInfo3 = { 3, 3, 3, 3, 3, "short3", "long3" };
2795	InfoLocationTester<VersionInfoValue, VersionInfoSetter, VersionInfoGetter,
2796					   VersionInfoChecker>(
2797		VersionInfoValue(versionInfo1, versionInfo1),
2798		VersionInfoValue(versionInfo2, versionInfo2),
2799		VersionInfoValue(versionInfo3, versionInfo3));
2800
2801	// icon for type
2802	NextSubTest();
2803	InfoLocationTester<IconForTypeValue, IconForTypeSetter, IconForTypeGetter,
2804					   IconForTypeChecker>(
2805		IconForTypeValue(fIconM1, fIconL1),
2806		IconForTypeValue(fIconM2, fIconL2),
2807		IconForTypeValue(fIconM3, fIconL3));
2808}
2809
2810