+ Updated Installed Types test slightly
+ Cleaned up warnings git-svn-id: file:///srv/svn/repos/haiku/trunk/current@901 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -102,8 +102,10 @@ static bool operator!=(BBitmap &bmp1, BBitmap &bmp2);
|
|||||||
static bool operator==(BMessage &msg1, BMessage &msg2);
|
static bool operator==(BMessage &msg1, BMessage &msg2);
|
||||||
static bool operator!=(BMessage &msg1, BMessage &msg2);
|
static bool operator!=(BMessage &msg1, BMessage &msg2);
|
||||||
static void fill_bitmap(BBitmap &bmp, char value);
|
static void fill_bitmap(BBitmap &bmp, char value);
|
||||||
static void dump_bitmap(BBitmap &bmp, char *name = "bmp");
|
//static void dump_bitmap(BBitmap &bmp, char *name = "bmp");
|
||||||
static status_t reduce_color_depth(BBitmap &src32, BBitmap &dest8);
|
#if !TEST_R5
|
||||||
|
static status_t reduce_color_depth(BBitmap &src32, BBitmap &dest8);
|
||||||
|
#endif
|
||||||
//static void dump_ref(entry_ref *ref, char* name = "ref");
|
//static void dump_ref(entry_ref *ref, char* name = "ref");
|
||||||
static void to_lower(const char *str, std::string &result);
|
static void to_lower(const char *str, std::string &result);
|
||||||
static std::string to_lower(const char *str);
|
static std::string to_lower(const char *str);
|
||||||
@@ -355,7 +357,7 @@ fill_bitmap32(BBitmap &bmp, char r, char g, char b, char a) {
|
|||||||
|
|
||||||
// Dumps the size, colorspace, and first data byte
|
// Dumps the size, colorspace, and first data byte
|
||||||
// of the bitmap to stdout
|
// of the bitmap to stdout
|
||||||
void
|
/*void
|
||||||
dump_bitmap(BBitmap &bmp, char *name = "bmp") {
|
dump_bitmap(BBitmap &bmp, char *name = "bmp") {
|
||||||
printf("%s == (%ldx%ld, ", name, bmp.Bounds().IntegerWidth()+1,
|
printf("%s == (%ldx%ld, ", name, bmp.Bounds().IntegerWidth()+1,
|
||||||
bmp.Bounds().IntegerHeight()+1);
|
bmp.Bounds().IntegerHeight()+1);
|
||||||
@@ -381,10 +383,11 @@ dump_bitmap(BBitmap &bmp, char *name = "bmp") {
|
|||||||
for (int i = 0; i < bmp.BitsLength() && i < 20; data++, i++)
|
for (int i = 0; i < bmp.BitsLength() && i < 20; data++, i++)
|
||||||
printf("%d,", *data);
|
printf("%d,", *data);
|
||||||
printf("]\n");
|
printf("]\n");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Uses BBitmap::SetBits() to convert the B_RGB32 bitmap in src32
|
// Uses BBitmap::SetBits() to convert the B_RGB32 bitmap in src32
|
||||||
// to a B_CMAP8 bitmap in dest8
|
// to a B_CMAP8 bitmap in dest8
|
||||||
|
#if !TEST_R5
|
||||||
status_t
|
status_t
|
||||||
reduce_color_depth(BBitmap &src32, BBitmap &dest8)
|
reduce_color_depth(BBitmap &src32, BBitmap &dest8)
|
||||||
{
|
{
|
||||||
@@ -399,7 +402,7 @@ reduce_color_depth(BBitmap &src32, BBitmap &dest8)
|
|||||||
// Set each pixel individually, since SetBits() for B_RGB32 takes
|
// Set each pixel individually, since SetBits() for B_RGB32 takes
|
||||||
// 24-bit rgb pixel data...
|
// 24-bit rgb pixel data...
|
||||||
char *data = (char*)src32.Bits();
|
char *data = (char*)src32.Bits();
|
||||||
for (uint32 i = 0; i*4+3 < src32.BitsLength(); data += 4, i++) {
|
for (int32 i = 0; i*4+3 < src32.BitsLength(); data += 4, i++) {
|
||||||
char rgb[3];
|
char rgb[3];
|
||||||
rgb[0] = data[2]; // red
|
rgb[0] = data[2]; // red
|
||||||
rgb[1] = data[1]; // green
|
rgb[1] = data[1]; // green
|
||||||
@@ -409,7 +412,7 @@ reduce_color_depth(BBitmap &src32, BBitmap &dest8)
|
|||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// IconHelper and IconForTypeHelper:
|
// IconHelper and IconForTypeHelper:
|
||||||
// Adapter(?) classes needed to reuse icon tests among {Get,Set}Icon() and {Get,Set}IconForType()
|
// Adapter(?) classes needed to reuse icon tests among {Get,Set}Icon() and {Get,Set}IconForType()
|
||||||
@@ -1607,7 +1610,10 @@ bool isMIMESupertype(const char *type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VerifyInstalledTypes() {
|
MimeTypeTest::VerifyInstalledTypes() {
|
||||||
|
// Check GetInstalledTypes(1)
|
||||||
|
NextSubTest();
|
||||||
|
{
|
||||||
BMessage msg;
|
BMessage msg;
|
||||||
|
|
||||||
// Get the list of installed types
|
// Get the list of installed types
|
||||||
@@ -1670,6 +1676,8 @@ VerifyInstalledTypes() {
|
|||||||
// Verify it's a valid mime string. If so, find and remove from our set
|
// Verify it's a valid mime string. If so, find and remove from our set
|
||||||
std::string subType = superLeaf + "/" + subLeaf;
|
std::string subType = superLeaf + "/" + subLeaf;
|
||||||
if (BMimeType::IsValid(subType.c_str())) {
|
if (BMimeType::IsValid(subType.c_str())) {
|
||||||
|
if (typeSet.find(subType.c_str()) == typeSet.end())
|
||||||
|
cout << "Fuckup == '" << subType << "'" << endl;
|
||||||
CHK(typeSet.find(subType.c_str()) != typeSet.end());
|
CHK(typeSet.find(subType.c_str()) != typeSet.end());
|
||||||
typeSet.erase(subType.c_str());
|
typeSet.erase(subType.c_str());
|
||||||
}
|
}
|
||||||
@@ -1681,67 +1689,9 @@ VerifyInstalledTypes() {
|
|||||||
// that you haven't added any superfluous files to your MIME database (like
|
// that you haven't added any superfluous files to your MIME database (like
|
||||||
// a __mime_table backup, for instance).
|
// a __mime_table backup, for instance).
|
||||||
CHK(typeSet.size() == 0);
|
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.
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
|
// Check GetInstalledTypes(2) and GetInstalledSupertypes()
|
||||||
{
|
{
|
||||||
BMessage msg;
|
BMessage msg;
|
||||||
|
|
||||||
@@ -1833,6 +1783,67 @@ MimeTypeTest::InstalledTypesTest() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Short Description
|
// Short Description
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1869,7 +1880,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
// Uninitialized
|
// Uninitialized
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
{
|
{
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
BMimeType mime;
|
BMimeType mime;
|
||||||
CPPUNIT_ASSERT(mime.InitCheck() == B_NO_INIT);
|
CPPUNIT_ASSERT(mime.InitCheck() == B_NO_INIT);
|
||||||
CPPUNIT_ASSERT((mime.*getDescr)(str) != B_OK); // R5 == B_BAD_VALUE
|
CPPUNIT_ASSERT((mime.*getDescr)(str) != B_OK); // R5 == B_BAD_VALUE
|
||||||
@@ -1878,7 +1889,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
// Non-installed type
|
// Non-installed type
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
{
|
{
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
BMimeType mime(testType);
|
BMimeType mime(testType);
|
||||||
CHK(mime.InitCheck() == B_OK);
|
CHK(mime.InitCheck() == B_OK);
|
||||||
// Make sure the type isn't installed
|
// Make sure the type isn't installed
|
||||||
@@ -1910,7 +1921,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
CHK(!mime.IsInstalled());
|
CHK(!mime.IsInstalled());
|
||||||
CHK((mime.*setDescr)(testDescr) == B_OK);
|
CHK((mime.*setDescr)(testDescr) == B_OK);
|
||||||
CHK(mime.IsInstalled());
|
CHK(mime.IsInstalled());
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK((mime.*getDescr)(str) == B_OK);
|
CHK((mime.*getDescr)(str) == B_OK);
|
||||||
CHK(strcmp(str, testDescr) == 0);
|
CHK(strcmp(str, testDescr) == 0);
|
||||||
CHK((mime.*setDescr)(NULL) == B_OK); // Delete the attribute
|
CHK((mime.*setDescr)(NULL) == B_OK); // Delete the attribute
|
||||||
@@ -1933,7 +1944,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
CHK(!mime.IsInstalled());
|
CHK(!mime.IsInstalled());
|
||||||
CHK((mime.*setDescr)(testDescr) == B_OK);
|
CHK((mime.*setDescr)(testDescr) == B_OK);
|
||||||
CHK(mime.IsInstalled());
|
CHK(mime.IsInstalled());
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK((mime.*getDescr)(str) == B_OK);
|
CHK((mime.*getDescr)(str) == B_OK);
|
||||||
CHK(strcmp(str, testDescr) == 0);
|
CHK(strcmp(str, testDescr) == 0);
|
||||||
CHK((mime.*deleteDescr)() == B_OK);
|
CHK((mime.*deleteDescr)() == B_OK);
|
||||||
@@ -1944,7 +1955,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
// Installed type
|
// Installed type
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
{
|
{
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
BMimeType mime(testType);
|
BMimeType mime(testType);
|
||||||
CHK(mime.InitCheck() == B_OK);
|
CHK(mime.InitCheck() == B_OK);
|
||||||
// Uninstall then reinstall to clear attributes
|
// Uninstall then reinstall to clear attributes
|
||||||
@@ -1967,7 +1978,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
|||||||
// Installed Type, Description Too Long
|
// Installed Type, Description Too Long
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
{
|
{
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK(strlen(longDescr) > (B_MIME_TYPE_LENGTH+1));
|
CHK(strlen(longDescr) > (B_MIME_TYPE_LENGTH+1));
|
||||||
BMimeType mime(testType);
|
BMimeType mime(testType);
|
||||||
CHK(mime.InitCheck() == B_OK);
|
CHK(mime.InitCheck() == B_OK);
|
||||||
@@ -2043,12 +2054,12 @@ MimeTypeTest::PreferredAppTest() {
|
|||||||
CHK(!mime.IsInstalled());
|
CHK(!mime.IsInstalled());
|
||||||
CHK(mime.SetPreferredApp(testSig) == B_OK);
|
CHK(mime.SetPreferredApp(testSig) == B_OK);
|
||||||
CHK(mime.IsInstalled());
|
CHK(mime.IsInstalled());
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK(mime.GetPreferredApp(str) == B_OK);
|
CHK(mime.GetPreferredApp(str) == B_OK);
|
||||||
CHK(strcmp(str, testSig) == 0);
|
CHK(strcmp(str, testSig) == 0);
|
||||||
CHK(mime.SetPreferredApp(NULL) == B_OK);
|
CHK(mime.SetPreferredApp(NULL) == B_OK);
|
||||||
CHK(mime.IsInstalled());
|
CHK(mime.IsInstalled());
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK(mime.GetPreferredApp(str) != B_OK); // OBOS == B_ENTRY_NOT_FOUND
|
CHK(mime.GetPreferredApp(str) != B_OK); // OBOS == B_ENTRY_NOT_FOUND
|
||||||
#endif // !TEST_R5
|
#endif // !TEST_R5
|
||||||
}
|
}
|
||||||
@@ -2082,7 +2093,7 @@ MimeTypeTest::PreferredAppTest() {
|
|||||||
CHK(!mime.IsInstalled());
|
CHK(!mime.IsInstalled());
|
||||||
CHK(mime.SetPreferredApp(testSig) == B_OK);
|
CHK(mime.SetPreferredApp(testSig) == B_OK);
|
||||||
CHK(mime.IsInstalled());
|
CHK(mime.IsInstalled());
|
||||||
sprintf(str, "");
|
str[0] = 0;
|
||||||
CHK(mime.GetPreferredApp(str) == B_OK);
|
CHK(mime.GetPreferredApp(str) == B_OK);
|
||||||
CHK(strcmp(str, testSig) == 0);
|
CHK(strcmp(str, testSig) == 0);
|
||||||
CHK(mime.DeletePreferredApp() == B_OK);
|
CHK(mime.DeletePreferredApp() == B_OK);
|
||||||
@@ -2411,7 +2422,6 @@ MimeTypeTest::SupportingAppsTest() {
|
|||||||
// Get the set of supporting apps for this type (and its supertype, if
|
// Get the set of supporting apps for this type (and its supertype, if
|
||||||
// it's not a supertype itself) that we discovered by manually culling
|
// it's not a supertype itself) that we discovered by manually culling
|
||||||
// the database
|
// the database
|
||||||
std::set<std::string> &appSet = typeAppMap[type]; // Reference the subtype
|
|
||||||
std::set<std::string> appSetSuper;
|
std::set<std::string> appSetSuper;
|
||||||
BMimeType superType;
|
BMimeType superType;
|
||||||
if (mime.GetSupertype(&superType) == B_OK)
|
if (mime.GetSupertype(&superType) == B_OK)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
void CheckNotificationMessages(const NotificationMessage *messages,
|
void CheckNotificationMessages(const NotificationMessage *messages,
|
||||||
int32 count);
|
int32 count);
|
||||||
|
void VerifyInstalledTypes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTestApp *fApplication;
|
BTestApp *fApplication;
|
||||||
|
|||||||
Reference in New Issue
Block a user