+ Updated InstalledTypesTest() to recheck GetInstalledTypes()
and friends after installing and deleting from the database. + Updated database dir constant per the recent mime migration git-svn-id: file:///srv/svn/repos/haiku/trunk/current@859 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include <Message.h>
|
||||
#include <Mime.h>
|
||||
#if !TEST_R5
|
||||
#include <MimeDatabase.h>
|
||||
#include <mime/database_support.h>
|
||||
#endif
|
||||
#include <MimeTypeTest.h>
|
||||
#include <Path.h> // Only needed for entry_ref dumps
|
||||
@@ -38,7 +38,7 @@ static const char *R5DatabaseDir = "/boot/home/config/settings/beos_mime";
|
||||
#if TEST_R5
|
||||
static std::string mimeDatabaseDir = R5DatabaseDir;
|
||||
#else
|
||||
static std::string mimeDatabaseDir = BPrivate::MimeDatabase::kDefaultDatabaseDir;
|
||||
static std::string mimeDatabaseDir = BPrivate::Storage::Mime::kDatabaseDir;
|
||||
#endif
|
||||
|
||||
// MIME Test Types
|
||||
@@ -1606,47 +1606,8 @@ bool isMIMESupertype(const char *type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
MimeTypeTest::InstalledTypesTest() {
|
||||
// NULL params
|
||||
{
|
||||
BMessage msg;
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes("text", NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
NextSubTest();
|
||||
CHK(BMimeType::GetInstalledTypes(NULL, &msg) == B_OK); // Same as GetInstalledTypes(&msg)
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes(NULL, NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledSupertypes(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
}
|
||||
// Invalid supertype param to GetInstalledTypes(char *super, BMessage*)
|
||||
{
|
||||
BMessage msg;
|
||||
NextSubTest();
|
||||
CHK(!BMimeType::IsValid(testTypeSuperInvalid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperInvalid, &msg) != B_OK); // R5 == B_BAD_VALUE
|
||||
NextSubTest();
|
||||
CHK(BMimeType::IsValid(testTypeSuperValid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperValid, &msg) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Normal Function -- GetInstalledTypes(BMessage*)
|
||||
// This test gets the list of installed types, then iterates through
|
||||
// the actual database directory listings and verifies they're identical.
|
||||
NextSubTest();
|
||||
{
|
||||
VerifyInstalledTypes() {
|
||||
BMessage msg;
|
||||
|
||||
// Get the list of installed types
|
||||
@@ -1721,6 +1682,62 @@ MimeTypeTest::InstalledTypesTest() {
|
||||
// a __mime_table backup, for instance).
|
||||
CHK(typeSet.size() == 0);
|
||||
}
|
||||
|
||||
void
|
||||
MimeTypeTest::InstalledTypesTest() {
|
||||
// NULL params
|
||||
{
|
||||
BMessage msg;
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::GetInstalledTypes(NULL) != B_OK); // R5 == CRASH!!!, OBOS == B_BAD_VALUE
|
||||
#endif
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::GetInstalledTypes("text", NULL) != B_OK); // R5 == CRASH!!!, OBOS == B_BAD_VALUE
|
||||
#endif
|
||||
NextSubTest();
|
||||
CHK(BMimeType::GetInstalledTypes(NULL, &msg) == B_OK); // Same as GetInstalledTypes(&msg)
|
||||
// msg.PrintToStream();
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::GetInstalledTypes(NULL, NULL) != B_OK); // R5 == CRASH!!!, OBOS == B_BAD_VALUE
|
||||
#endif
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::GetInstalledSupertypes(NULL) != B_OK); // R5 == CRASH!!!, OBOS == B_BAD_VALUE
|
||||
#endif
|
||||
}
|
||||
// Invalid supertype param to GetInstalledTypes(char *super, BMessage*)
|
||||
{
|
||||
BMessage msg;
|
||||
NextSubTest();
|
||||
CHK(!BMimeType::IsValid(testTypeSuperInvalid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperInvalid, &msg) != B_OK); // R5 == B_BAD_VALUE
|
||||
NextSubTest();
|
||||
CHK(BMimeType::IsValid(testTypeSuperValid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperValid, &msg) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Normal Function -- GetInstalledTypes(BMessage*)
|
||||
// This test gets the list of installed types, then iterates through
|
||||
// the actual database directory listings and verifies they're identical.
|
||||
NextSubTest();
|
||||
{
|
||||
VerifyInstalledTypes();
|
||||
BMimeType mime(testTypeApp1);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
if (mime.IsInstalled()) {
|
||||
CHK(mime.Delete() == B_OK);
|
||||
VerifyInstalledTypes();
|
||||
CHK(mime.Install() == B_OK);
|
||||
VerifyInstalledTypes();
|
||||
} else {
|
||||
CHK(mime.Install() == B_OK);
|
||||
VerifyInstalledTypes();
|
||||
CHK(mime.Delete() == B_OK);
|
||||
VerifyInstalledTypes();
|
||||
}
|
||||
}
|
||||
// Normal Function -- GetInstalledSupertypes()/GetInstalledTypes(char*,BMessage*)
|
||||
// This test gets the list of installed super types, then iterates through
|
||||
// the actual database directory listings and verifies they're identical.
|
||||
@@ -1730,6 +1747,7 @@ MimeTypeTest::InstalledTypesTest() {
|
||||
|
||||
// Get the list of installed types
|
||||
CHK(BMimeType::GetInstalledSupertypes(&msg) == B_OK);
|
||||
// msg.PrintToStream();
|
||||
|
||||
// Add all the type strings to a std::set
|
||||
std::set<std::string> typeSet;
|
||||
@@ -1769,6 +1787,8 @@ MimeTypeTest::InstalledTypesTest() {
|
||||
// to a std::set to be used for verification
|
||||
BMessage msg;
|
||||
CHK(BMimeType::GetInstalledTypes(superLeaf.c_str(), &msg) == B_OK);
|
||||
// msg.PrintToStream();
|
||||
|
||||
std::set<std::string> subtypeSet;
|
||||
SetAdapter subtypeAdapter(subtypeSet);
|
||||
FillWithMimeTypes(subtypeAdapter, msg, "types");
|
||||
|
||||
Reference in New Issue
Block a user