* Re-enabled the tests for data-only-based MIME type sniffing. Had to
disable the special test for sniffing a MIME type file (as stored in the MIME DB), since the framework is not really prepared to deal with that. * Removed left-over debug code. * Fixed a nasty `use of member of temporary object' bug. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10689 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4726,12 +4726,17 @@ MimeTypeTest::SniffingTest()
|
|||||||
SniffingTestFile(string(testDir) + "/file13", "", "",
|
SniffingTestFile(string(testDir) + "/file13", "", "",
|
||||||
"LNNO"),
|
"LNNO"),
|
||||||
// meta mime test
|
// meta mime test
|
||||||
#if !TEST_R5
|
// bonefish: TODO: Now that content sniffing is enabled again, this doesn't
|
||||||
SniffingTestFile(string(testDir) + "/file14.html",
|
// work properly anymore, since there are actually three types involved: The
|
||||||
"text/html", "application/x-vnd.be-meta-mime",
|
// extension type ("text/html"), the content type (also "text/html") and the
|
||||||
"<html>\n<body>\n</body></html>\n", -1,
|
// real type ("application/x-vnd.be-meta-mime") which is concluded from the
|
||||||
"fake-meta-mime-string"),
|
// existence of the "META:TYPE" attribute rather than the extension or content.
|
||||||
#endif // !TEST_R5
|
//#if !TEST_R5
|
||||||
|
// SniffingTestFile(string(testDir) + "/file14.html",
|
||||||
|
// "text/html", "application/x-vnd.be-meta-mime",
|
||||||
|
// "<html>\n<body>\n</body></html>\n", -1,
|
||||||
|
// "fake-meta-mime-string"),
|
||||||
|
//#endif // !TEST_R5
|
||||||
};
|
};
|
||||||
int fileCount = sizeof(files) / sizeof(SniffingTestFile);
|
int fileCount = sizeof(files) / sizeof(SniffingTestFile);
|
||||||
for (int32 i = 0; i < fileCount; i++) {
|
for (int32 i = 0; i < fileCount; i++) {
|
||||||
@@ -4747,9 +4752,9 @@ MimeTypeTest::SniffingTest()
|
|||||||
// GuessMimeType(const char*,)
|
// GuessMimeType(const char*,)
|
||||||
BMimeType type;
|
BMimeType type;
|
||||||
CHK(BMimeType::GuessMimeType(filename, &type) == B_OK);
|
CHK(BMimeType::GuessMimeType(filename, &type) == B_OK);
|
||||||
|
//printf("type: `%s', extensionType: `%s'\n", type.Type(), extensionType);
|
||||||
CHK(type == extensionType);
|
CHK(type == extensionType);
|
||||||
type.Unset();
|
type.Unset();
|
||||||
/*
|
|
||||||
// GuessMimeType(const void*, int32,)
|
// GuessMimeType(const void*, int32,)
|
||||||
if (file.data != NULL) {
|
if (file.data != NULL) {
|
||||||
CHK(BMimeType::GuessMimeType(file.data, file.size, &type) == B_OK);
|
CHK(BMimeType::GuessMimeType(file.data, file.size, &type) == B_OK);
|
||||||
@@ -4758,7 +4763,6 @@ printf("type: %s, should be: %s\n", type.Type(), realType);
|
|||||||
CHK(type == contentType);
|
CHK(type == contentType);
|
||||||
type.Unset();
|
type.Unset();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
CHK(file.Create() == B_OK);
|
CHK(file.Create() == B_OK);
|
||||||
// set BEOS:TYPE to something confusing ;-)
|
// set BEOS:TYPE to something confusing ;-)
|
||||||
BNode node;
|
BNode node;
|
||||||
@@ -4767,9 +4771,6 @@ printf("type: %s, should be: %s\n", type.Type(), realType);
|
|||||||
// GuessMimeType(const ref*,)
|
// GuessMimeType(const ref*,)
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
CHK(get_ref_for_path(filename, &ref) == B_OK);
|
CHK(get_ref_for_path(filename, &ref) == B_OK);
|
||||||
char thing[1024];
|
|
||||||
sprintf(thing, "cat %s > /boot/home/Desktop/out.txt", filename);
|
|
||||||
system(thing);
|
|
||||||
CHK(BMimeType::GuessMimeType(&ref, &type) == B_OK);
|
CHK(BMimeType::GuessMimeType(&ref, &type) == B_OK);
|
||||||
if (!(type == realType))
|
if (!(type == realType))
|
||||||
printf("type: %s, should be: %s (file == '%s')\n", type.Type(), realType, filename);
|
printf("type: %s, should be: %s (file == '%s')\n", type.Type(), realType, filename);
|
||||||
@@ -4781,7 +4782,7 @@ printf("type: %s, should be: %s (file == '%s')\n", type.Type(), realType, filena
|
|||||||
// GuessMimeType(const ref*,), invalid/abstract entry
|
// GuessMimeType(const ref*,), invalid/abstract entry
|
||||||
{
|
{
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
const char *filename = (string(testDir) + "/file100.cpp").c_str();
|
string filename = string(testDir) + "/file100.cpp";
|
||||||
BMimeType type;
|
BMimeType type;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
// invalid entry_ref: R5: Is fine! OBOS: no dice
|
// invalid entry_ref: R5: Is fine! OBOS: no dice
|
||||||
@@ -4792,7 +4793,7 @@ printf("type: %s, should be: %s (file == '%s')\n", type.Type(), realType, filena
|
|||||||
CHK(BMimeType::GuessMimeType(&ref, &type) != B_OK);
|
CHK(BMimeType::GuessMimeType(&ref, &type) != B_OK);
|
||||||
#endif
|
#endif
|
||||||
// abstract entry_ref
|
// abstract entry_ref
|
||||||
CHK(get_ref_for_path(filename, &ref) == B_OK);
|
CHK(get_ref_for_path(filename.c_str(), &ref) == B_OK);
|
||||||
// R5: B_NAME_NOT_FOUND, OBOS:
|
// R5: B_NAME_NOT_FOUND, OBOS:
|
||||||
CHK(BMimeType::GuessMimeType(&ref, &type) != B_OK);
|
CHK(BMimeType::GuessMimeType(&ref, &type) != B_OK);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user