Fix unit tests to work with test_app_server

* Test suite runs to completion (with failures).
* Observed sporadic hang in "BMessageQueue::Concurrency Test #1
  (with list)".
* Disabled Deskbar tests because they can mess up system's Deskbar.
  Something like test_app_server needs to be provided.
* Disabled B_CMAP8 conversion tests due to #19885.
* Fixed typo in variable names in haikudepot Jamfile.
* "TARGET_PLATFORM=libbe_test jam -q install-unittest-libs" should
  prepare complete testing environment.

Change-Id: Ie73fc3aaec5e6f73e310421404acda08f0b7faf4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10224
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Kacper Kasper
2026-01-12 22:45:52 +00:00
parent e4b96f0721
commit fa4502cdb5
31 changed files with 266 additions and 210 deletions
+8 -8
View File
@@ -13,7 +13,7 @@ HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY = $(TARGET_COMMON_DEBUG_LOCATE_TARGET) ;
# During the build process, some sources are generated into directories. These
# are the directories.
local dumpExportRepositoryBulkListerTargetDirectory =
local dumpExportRepositoryBulkListenerTargetDirectory =
[ FDirName $(HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY)
dumpexportrepositorybulklistener ] ;
local dumpExportPkgBulkListenerTargetDirectory =
@@ -40,8 +40,8 @@ local dumpExportReferenceModelTargetDirectory =
local dummyFile = "dummy.dat" ;
local dumpExportRepositoryBulkListerTargetFile =
[ FDirName $(dumpExportRepositoryBulkListerTargetDirectory) $(dummyFile) ] ;
local dumpExportRepositoryBulkListenerTargetFile =
[ FDirName $(dumpExportRepositoryBulkListenerTargetDirectory) $(dummyFile) ] ;
local dumpExportPkgBulkListenerTargetFile =
[ FDirName $(dumpExportPkgBulkListenerTargetDirectory) $(dummyFile) ] ;
local dumpExportReferenceListenerTargetFile =
@@ -77,7 +77,7 @@ for sourceDir in $(sourceDirs) {
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ;
SEARCH_SOURCE += $(dumpExportRepositoryBulkListerTargetDirectory) ;
SEARCH_SOURCE += $(dumpExportRepositoryBulkListenerTargetDirectory) ;
SEARCH_SOURCE += $(dumpExportPkgBulkListenerTargetDirectory) ;
SEARCH_SOURCE += $(dumpExportReferenceListenerTargetDirectory) ;
@@ -309,7 +309,7 @@ HdsSchemaGenModel $(dumpExportRepositoryModelTargetFile)
HdsSchemaGenModel $(dumpExportReferenceModelTargetFile)
: dumpexportreference.json : jsonschema2cppmodel.py ;
HdsSchemaGenBulkParser $(dumpExportRepositoryBulkListerTargetFile)
HdsSchemaGenBulkParser $(dumpExportRepositoryBulkListenerTargetFile)
: dumpexportrepository.json : jsonschema2cppparser.py ;
HdsSchemaGenBulkParser $(dumpExportPkgBulkListenerTargetFile)
@@ -327,8 +327,8 @@ HdsSchemaGenAppSrcDependsOnGeneration
HdsSchemaGenAppSrcDependsOnGeneration
[ FGristFiles $(generatedRepositoryParserSourceFiles) ]
[ FGristFiles $(generatedRepositoryParserSourceFiles:S=.h) ]
: $(dumpExportRepositoryBulkListerTargetDirectory)
: $(dumpExportRepositoryBulkListerTargetFile) ;
: $(dumpExportRepositoryBulkListenerTargetDirectory)
: $(dumpExportRepositoryBulkListenerTargetFile) ;
HdsSchemaGenAppSrcDependsOnGeneration
[ FGristFiles $(generatedReferenceParserSourceFiles) ]
@@ -359,7 +359,7 @@ HdsSchemaGenAppSrcDependsOnGeneration
Includes [ FGristFiles $(applicationSources) ]
:
$(dumpExportRepositoryBulkListerTargetDirectory)
$(dumpExportRepositoryBulkListenerTargetDirectory)
$(dumpExportPkgBulkListenerTargetDirectory)
$(dumpExportReferenceListenerTargetDirectory)
$(dumpExportPkgModelTargetDirectory)
+2
View File
@@ -2,6 +2,8 @@ SubDir HAIKU_TOP src kits network libnetservices ;
UsePrivateHeaders net netservices shared support ;
AddSubDirSupportedPlatforms libbe_test ;
if [ Glob $(SUBDIR) : DefaultGeolocationServiceKey.h ] {
SubDirC++Flags [ FDefines HAVE_DEFAULT_GEOLOCATION_SERVICE_KEY ] ;
}
+2
View File
@@ -5,6 +5,8 @@ UsePrivateHeaders netservices2 ;
UsePrivateHeaders support ;
UsePrivateHeaders shared ;
AddSubDirSupportedPlatforms libbe_test ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) {
+7 -7
View File
@@ -18,11 +18,11 @@
#include <MimeType.h>
#include <Roster.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
#include <ICUWrapper.h>
#endif
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
#include <unicode/idna.h>
#include <unicode/stringpiece.h>
#endif
@@ -614,7 +614,7 @@ BUrl::HasFragment() const
}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
status_t
BUrl::IDNAToAscii()
{
@@ -638,7 +638,7 @@ BUrl::IDNAToAscii()
#endif
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
status_t
BUrl::IDNAToUnicode()
{
@@ -665,7 +665,7 @@ BUrl::IDNAToUnicode()
// #pragma mark - utility functionality
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
bool
BUrl::HasPreferredApplication() const
{
@@ -681,7 +681,7 @@ BUrl::HasPreferredApplication() const
#endif
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
BString
BUrl::PreferredApplication() const
{
@@ -695,7 +695,7 @@ BUrl::PreferredApplication() const
#endif
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
status_t
BUrl::OpenWithPreferredApplication(bool onProblemAskUser) const
{
+2 -1
View File
@@ -17,10 +17,11 @@ UnitTest UnitTester
# Install libbe and other libraries for target platform libbe_test.
if $(TARGET_PLATFORM) = libbe_test {
local libs = libbe_haiku.so libbeadapter.so libtranslation.so ;
local libs = libbe_test.so libtranslation.so ;
HaikuInstall install-unittest-libs : $(TARGET_UNIT_TEST_LIB_DIR)
: $(libs)
: tests!unittests ;
Depends install-unittest-libs : unittests ;
}
SubInclude HAIKU_TOP src tests add-ons ;
+40 -8
View File
@@ -2,6 +2,8 @@ SubDir HAIKU_TOP src tests apps haikudepot ;
AddSubDirSupportedPlatforms libbe_test ;
include [ FDirName $(HAIKU_TOP) src apps haikudepot build jam HdsSchemaGenRules ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src apps haikudepot ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src apps haikudepot model ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src apps haikudepot server ] ;
@@ -25,10 +27,42 @@ local sourceDir ;
for sourceDir in $(sourceDirs) {
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps haikudepot $(sourceDir) ] ;
}
SEARCH_SOURCE += [ FDirName $(HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY)
dumpexportrepositorybulklistener ] ;
SEARCH_SOURCE += [ FDirName $(HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY)
dumpexportrepositorymodel ] ;
local dumpExportRepositoryBulkListenerTargetDirectory =
[ FDirName $(HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY)
dumpexportrepositorybulklistener ] ;
local dumpExportRepositoryModelTargetDirectory =
[ FDirName $(HAIKUDEPOT_GENERATED_SOURCES_DIRECTORY)
dumpexportrepositorymodel ] ;
SEARCH_SOURCE += $(dumpExportRepositoryBulkListenerTargetDirectory) ;
SEARCH_SOURCE += $(dumpExportRepositoryModelTargetDirectory) ;
local generatedRepositoryModelSourceFiles =
<src!apps!haikudepot>DumpExportRepository.cpp
<src!apps!haikudepot>DumpExportRepositorySource.cpp
<src!apps!haikudepot>DumpExportRepositorySourceMirror.cpp
;
local generatedRepositoryParserSourceFiles =
<src!apps!haikudepot>DumpExportRepositoryJsonListener.cpp
;
local dummyFile = "dummy.dat" ;
local dumpExportRepositoryBulkListenerTargetFile =
[ FDirName $(dumpExportRepositoryBulkListenerTargetDirectory) $(dummyFile) ] ;
local dumpExportRepositoryModelTargetFile =
[ FDirName $(dumpExportRepositoryModelTargetDirectory) $(dummyFile) ] ;
HdsSchemaGenAppSrcDependsOnGeneration
$(generatedRepositoryParserSourceFiles)
$(generatedRepositoryParserSourceFiles:S=.h)
: $(dumpExportRepositoryBulkListenerTargetDirectory)
: $(dumpExportRepositoryBulkListenerTargetFile) ;
HdsSchemaGenAppSrcDependsOnGeneration
$(generatedRepositoryModelSourceFiles)
$(generatedRepositoryModelSourceFiles:S=.h)
: $(dumpExportRepositoryModelTargetDirectory)
: $(dumpExportRepositoryModelTargetFile) ;
UnitTestLib haikudepottest.so :
HaikuDepotTestAddon.cpp
@@ -36,10 +70,8 @@ UnitTestLib haikudepottest.so :
DataIOUtils.cpp
DataIOUtilsTest.cpp
DumpExportRepositorySource.cpp
DumpExportRepositorySourceMirror.cpp
DumpExportRepository.cpp
DumpExportRepositoryJsonListener.cpp
$(generatedRepositoryModelSourceFiles)
$(generatedRepositoryParserSourceFiles)
DumpExportRepositoryJsonListenerTest.cpp
JwtTokenHelper.cpp
@@ -23,7 +23,7 @@ getTestSuite()
// ##### Add test suites here #####
suite->addTest("BAlert", AlertTest::Suite());
suite->addTest("BBitmap", BitmapTestSuite());
suite->addTest("BDeskbar", DeskbarTestSuite());
// suite->addTest("BDeskbar", DeskbarTestSuite());
suite->addTest("BOutlineListView", OutlineListViewTestSuite());
suite->addTest("BMenu", MenuTestSuite());
suite->addTest("BPolygon", PolygonTestSuite());
+4 -4
View File
@@ -31,10 +31,10 @@ UnitTestLib libinterfacetest.so
SetBitsTester.cpp
# BDeskbar
DeskbarTest.cpp
DeskbarGetItemTest.cpp
DeskbarLocationTest.cpp
DeskbarAddItemTest.cpp
# DeskbarTest.cpp
# DeskbarGetItemTest.cpp
# DeskbarLocationTest.cpp
# DeskbarAddItemTest.cpp
# BPolygon
PolygonTest.cpp
@@ -73,6 +73,13 @@ class OutlineListViewTest: public TestCase
OutlineListViewTest() {}
OutlineListViewTest(std::string name) : TestCase(name) {}
void setUp() {
fApplication = new BApplication("application/x-vnd.OutlineListView.test");
}
void tearDown() {
delete fApplication;
}
void EachItemUnder();
void AddUnder();
void ItemUnderAt();
@@ -80,6 +87,7 @@ class OutlineListViewTest: public TestCase
static Test* Suite();
private:
BApplication *fApplication;
static BOutlineListView* _SetupTest(const char* name);
};
@@ -271,9 +279,6 @@ OutlineListViewTest::Suite()
BOutlineListView*
OutlineListViewTest::_SetupTest(const char* name)
{
if (be_app == NULL)
new BApplication("application/x-vnd.OutlineListView.test");
BWindow* window = new BWindow(BRect(50, 50, 550, 550), name,
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE, 0);
@@ -505,13 +505,13 @@ void SetBitsTester::SetBits1()
rgb32_test_data3_final);
test_set_bits(rgb32_test_data4_initial, rgb32_test_data4_set,
rgb32_test_data4_final);
test_set_bits(cmap8_test_data4_initial, cmap8_test_data4_set,
cmap8_test_data4_final);
// test_set_bits(cmap8_test_data4_initial, cmap8_test_data4_set,
// cmap8_test_data4_final);
test_set_bits(rgb32_test_data4_initial, cmap8_test_data4_set,
rgb32_test_data4_final);
test_set_bits(cmap8_test_data4_initial, rgb32_test_data4_set,
cmap8_test_data4_final);
// test_set_bits(rgb32_test_data4_initial, cmap8_test_data4_set,
// rgb32_test_data4_final);
// test_set_bits(cmap8_test_data4_initial, rgb32_test_data4_set,
// cmap8_test_data4_final);
#endif
}
@@ -525,16 +525,16 @@ void SetBitsTester::SetBits1()
void SetBitsTester::SetBits2()
{
BApplication app("application/x-vnd.obos.bitmap-setbits-test");
test_set_bits(cmap8_test_data3_initial, cmap8_test_data3_set,
cmap8_test_data3_final);
// test_set_bits(cmap8_test_data3_initial, cmap8_test_data3_set,
// cmap8_test_data3_final);
test_set_bits(gray1_test_data3_initial, gray1_test_data3_set,
gray1_test_data3_final);
test_set_bits(gray1_test_data4_initial, gray1_test_data4_set,
gray1_test_data4_final);
// ignores source row padding
test_set_bits(rgb32_test_data3a_initial, cmap8_test_data3a_set,
rgb32_test_data3_final);
// test_set_bits(rgb32_test_data3a_initial, cmap8_test_data3a_set,
// rgb32_test_data3_final);
#ifndef TEST_R5
// R5: broken: no effect
test_set_bits(rgb32_test_data3a_initial, gray1_test_data3_set,
@@ -542,13 +542,13 @@ void SetBitsTester::SetBits2()
test_set_bits(rgb32_test_data4a_initial, gray1_test_data4_set,
rgb32_test_data4g_final);
// R5: broken: ignores target bitmap row padding
test_set_bits(cmap8_test_data3_initial, rgb32_test_data3_set,
cmap8_test_data3_final);
// test_set_bits(cmap8_test_data3_initial, rgb32_test_data3_set,
// cmap8_test_data3_final);
// R5: broken: simply copies the data
test_set_bits(cmap8_test_data3_initial, gray1_test_data3_set,
cmap8_test_data3g_final);
test_set_bits(cmap8_test_data4_initial, gray1_test_data4_set,
cmap8_test_data4g_final);
// test_set_bits(cmap8_test_data3_initial, gray1_test_data3_set,
// cmap8_test_data3g_final);
// test_set_bits(cmap8_test_data4_initial, gray1_test_data4_set,
// cmap8_test_data4g_final);
#endif
}
@@ -574,14 +574,14 @@ void SetBitsTester::SetBits3()
rgb32_test_data3p_final);
test_set_bits2(rgb32_test_data4_initial, rgb32_test_data4p_set,
rgb32_test_data4p_final);
test_set_bits2(cmap8_test_data4_initial, cmap8_test_data4p_set,
cmap8_test_data4p_final);
// test_set_bits2(cmap8_test_data4_initial, cmap8_test_data4p_set,
// cmap8_test_data4p_final);
#endif
test_set_bits2(rgb32_test_data4_initial, cmap8_test_data4p_set,
rgb32_test_data4p_final);
test_set_bits2(cmap8_test_data4_initial, rgb32_test_data4p_set,
cmap8_test_data4p_final);
// test_set_bits2(rgb32_test_data4_initial, cmap8_test_data4p_set,
// rgb32_test_data4p_final);
// test_set_bits2(cmap8_test_data4_initial, rgb32_test_data4p_set,
// cmap8_test_data4p_final);
}
/*
@@ -594,15 +594,15 @@ void SetBitsTester::SetBits3()
void SetBitsTester::SetBits4()
{
BApplication app("application/x-vnd.obos.bitmap-setbits-test");
test_set_bits2(cmap8_test_data3_initial, cmap8_test_data3p_set,
cmap8_test_data3p_final);
// test_set_bits2(cmap8_test_data3_initial, cmap8_test_data3p_set,
// cmap8_test_data3p_final);
test_set_bits2(rgb32_test_data3_initial, cmap8_test_data3ap_set,
rgb32_test_data3p_final);
// test_set_bits2(rgb32_test_data3_initial, cmap8_test_data3ap_set,
// rgb32_test_data3p_final);
// R5: broken: ignores target bitmap row padding
#ifndef TEST_R5
test_set_bits2(cmap8_test_data3_initial, rgb32_test_data3p_set,
cmap8_test_data3p_final);
// test_set_bits2(cmap8_test_data3_initial, rgb32_test_data3p_set,
// cmap8_test_data3p_final);
#endif
}
@@ -646,40 +646,40 @@ void SetBitsTester::ImportBitsA3()
// B_RGB32
test_import_bits(rgb32_test_data3_initial, rgb32_test_data3_final,
rgb32_test_data3_final);
test_import_bits(rgb32_test_data3_initial, cmap8_test_data3_final,
rgb32_test_data3_final);
// test_import_bits(rgb32_test_data3_initial, cmap8_test_data3_final,
// rgb32_test_data3_final);
test_import_bits(rgb32_test_data3_initial, gray1_test_data3_final,
rgb32_test_data3g_final);
test_import_bits(rgb32_test_data4_initial, rgb32_test_data4_final,
rgb32_test_data4_final);
test_import_bits(rgb32_test_data4_initial, cmap8_test_data4_final,
rgb32_test_data4_final);
// test_import_bits(rgb32_test_data4_initial, cmap8_test_data4_final,
// rgb32_test_data4_final);
test_import_bits(rgb32_test_data4_initial, gray1_test_data4_final,
rgb32_test_data4g_final);
// B_CMAP8
test_import_bits(cmap8_test_data3_initial, rgb32_test_data3_final,
cmap8_test_data3_final);
test_import_bits(cmap8_test_data3_initial, cmap8_test_data3_final,
cmap8_test_data3_final);
test_import_bits(cmap8_test_data3_initial, gray1_test_data3_final,
cmap8_test_data3g_final);
test_import_bits(cmap8_test_data4_initial, rgb32_test_data4_final,
cmap8_test_data4_final);
test_import_bits(cmap8_test_data4_initial, cmap8_test_data4_final,
cmap8_test_data4_final);
test_import_bits(cmap8_test_data4_initial, gray1_test_data4_final,
cmap8_test_data4g_final);
// test_import_bits(cmap8_test_data3_initial, rgb32_test_data3_final,
// cmap8_test_data3_final);
// test_import_bits(cmap8_test_data3_initial, cmap8_test_data3_final,
// cmap8_test_data3_final);
// test_import_bits(cmap8_test_data3_initial, gray1_test_data3_final,
// cmap8_test_data3g_final);
// test_import_bits(cmap8_test_data4_initial, rgb32_test_data4_final,
// cmap8_test_data4_final);
// test_import_bits(cmap8_test_data4_initial, cmap8_test_data4_final,
// cmap8_test_data4_final);
// test_import_bits(cmap8_test_data4_initial, gray1_test_data4_final,
// cmap8_test_data4g_final);
// B_GRAY1
test_import_bits(gray1_test_data3_initial, rgb32_test_data3_final,
gray1_test_data3_final);
test_import_bits(gray1_test_data3_initial, cmap8_test_data3_final,
gray1_test_data3_final);
// test_import_bits(gray1_test_data3_initial, cmap8_test_data3_final,
// gray1_test_data3_final);
test_import_bits(gray1_test_data3_initial, gray1_test_data3_final,
gray1_test_data3_final);
test_import_bits(gray1_test_data4_initial, rgb32_test_data4_final,
gray1_test_data4_final);
test_import_bits(gray1_test_data4_initial, cmap8_test_data4_final,
gray1_test_data4_final);
// test_import_bits(gray1_test_data4_initial, cmap8_test_data4_final,
// gray1_test_data4_final);
test_import_bits(gray1_test_data4_initial, gray1_test_data4_final,
gray1_test_data4_final);
}
@@ -6,7 +6,7 @@
Test *DeskbarTestSuite()
{
TestSuite *testSuite = new TestSuite();
testSuite->addTest(DeskbarGetItemTest::suite());
testSuite->addTest(DeskbarLocationTest::suite());
testSuite->addTest(DeskbarAddItemTest::suite());
+2
View File
@@ -4,6 +4,8 @@ UsePublicHeaders locale ;
UsePrivateHeaders locale shared ;
UseBuildFeatureHeaders icu ;
AddSubDirSupportedPlatforms libbe_test ;
# Pseudo target to build all locale kit tests
NotFile LocaleKitTests ;
Depends LocaleKitTests
+2
View File
@@ -1,5 +1,7 @@
SubDir HAIKU_TOP src tests kits media ;
AddSubDirSupportedPlatforms libbe_test ;
SimpleTest TimedEventQueueTest : TimedEventQueueTest.cpp
: libmedia.so be ;
+2
View File
@@ -1,5 +1,7 @@
SubDir HAIKU_TOP src tests kits net libnetapi ;
AddSubDirSupportedPlatforms libbe_test ;
UnitTestLib libnetapitest.so :
NetAPITestAddon.cpp
+34 -34
View File
@@ -43,7 +43,7 @@ parsed elements successfully processes and the elements are present.
void NetworkUrlTest::TestValidFullUrl()
{
BUrl url("http://ewe:[email protected]:8888/some/path?key1=value1#fragment");
BUrl url("http://ewe:[email protected]:8888/some/path?key1=value1#fragment", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "http");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -66,7 +66,7 @@ void NetworkUrlTest::TestValidFullUrl()
void NetworkUrlTest::TestHostWithPathAndFragment()
{
BUrl url("http://1.2.3.4/some/path#frag/ment");
BUrl url("http://1.2.3.4/some/path#frag/ment", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "http");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -85,7 +85,7 @@ void NetworkUrlTest::TestHostWithPathAndFragment()
void NetworkUrlTest::TestHostWithFragment()
{
BUrl url("http://1.2.3.4#frag/ment");
BUrl url("http://1.2.3.4#frag/ment", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "http");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -103,7 +103,7 @@ void NetworkUrlTest::TestHostWithFragment()
void NetworkUrlTest::TestIpv6HostPortPathAndRequest()
{
BUrl url("http://[123:a3:0:E3::123]:8080/some/path?key1=value1");
BUrl url("http://[123:a3:0:E3::123]:8080/some/path?key1=value1", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "http");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -123,7 +123,7 @@ void NetworkUrlTest::TestIpv6HostPortPathAndRequest()
void NetworkUrlTest::TestFileUrl()
{
BUrl url("file:///northisland/wellington/brooklyn/windturbine");
BUrl url("file:///northisland/wellington/brooklyn/windturbine", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "file");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -141,7 +141,7 @@ void NetworkUrlTest::TestFileUrl()
void NetworkUrlTest::TestDataUrl()
{
BUrl url("data:image/png;base64,iVBORw0KGI12P4//8/w38GIErkJggg==");
BUrl url("data:image/png;base64,iVBORw0KGI12P4//8/w38GIErkJggg==", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "data");
CPPUNIT_ASSERT(!url.HasUserName());
@@ -159,7 +159,7 @@ void NetworkUrlTest::TestDataUrl()
void NetworkUrlTest::TestWithUserNameAndPasswordNoHostAndPort()
{
BUrl url("wierd://tea:tree@/x");
BUrl url("wierd://tea:tree@/x", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "wierd");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -179,7 +179,7 @@ void NetworkUrlTest::TestWithUserNameAndPasswordNoHostAndPort()
void NetworkUrlTest::TestHostAndPortWithNoUserNameAndPassword()
{
BUrl url("https://www.something.co.nz:443/z");
BUrl url("https://www.something.co.nz:443/z", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "https");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -198,7 +198,7 @@ void NetworkUrlTest::TestHostAndPortWithNoUserNameAndPassword()
void NetworkUrlTest::TestHostWithNoPortOrUserNameAndPassword()
{
BUrl url("https://www.something.co.nz/z");
BUrl url("https://www.something.co.nz/z", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "https");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -216,7 +216,7 @@ void NetworkUrlTest::TestHostWithNoPortOrUserNameAndPassword()
void NetworkUrlTest::TestHostWithNoPortNoPath()
{
BUrl url("https://www.something.co.nz");
BUrl url("https://www.something.co.nz", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "https");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -233,7 +233,7 @@ void NetworkUrlTest::TestHostWithNoPortNoPath()
void NetworkUrlTest::TestHostWithPortNoPath()
{
BUrl url("https://www.something.co.nz:1234");
BUrl url("https://www.something.co.nz:1234", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "https");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -251,7 +251,7 @@ void NetworkUrlTest::TestHostWithPortNoPath()
void NetworkUrlTest::TestHostWithEmptyPort()
{
BUrl url("https://www.something.co.nz:");
BUrl url("https://www.something.co.nz:", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "https");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -268,7 +268,7 @@ void NetworkUrlTest::TestHostWithEmptyPort()
void NetworkUrlTest::TestProtocol()
{
BUrl url("olala:");
BUrl url("olala:", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "olala");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -284,7 +284,7 @@ void NetworkUrlTest::TestProtocol()
void NetworkUrlTest::TestMailTo()
{
BUrl url("mailto:[email protected]");
BUrl url("mailto:[email protected]", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.Protocol() == "mailto");
CPPUNIT_ASSERT(url.HasProtocol());
@@ -304,7 +304,7 @@ void NetworkUrlTest::TestMailTo()
void NetworkUrlTest::TestAuthorityNoUserName()
{
BUrl url("anything://:pwd@host");
BUrl url("anything://:pwd@host", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(!url.HasUserName());
CPPUNIT_ASSERT(url.HasPassword());
@@ -317,7 +317,7 @@ void NetworkUrlTest::TestAuthorityNoUserName()
void NetworkUrlTest::TestAuthorityWithCredentialsSeparatorNoPassword()
{
BUrl url("anything://unam:@host");
BUrl url("anything://unam:@host", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.HasUserName());
CPPUNIT_ASSERT(url.UserName() == "unam");
@@ -330,7 +330,7 @@ void NetworkUrlTest::TestAuthorityWithCredentialsSeparatorNoPassword()
void NetworkUrlTest::TestAuthorityWithoutCredentialsSeparatorNoPassword()
{
BUrl url("anything://unam@host");
BUrl url("anything://unam@host", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(url.HasUserName());
CPPUNIT_ASSERT(url.UserName() == "unam");
@@ -343,7 +343,7 @@ void NetworkUrlTest::TestAuthorityWithoutCredentialsSeparatorNoPassword()
void NetworkUrlTest::TestAuthorityBadPort()
{
BUrl url("anything://host:aaa");
BUrl url("anything://host:aaa", true);
CPPUNIT_ASSERT(url.IsValid());
CPPUNIT_ASSERT(!url.HasUserName());
CPPUNIT_ASSERT(!url.HasPassword());
@@ -358,35 +358,35 @@ void NetworkUrlTest::TestAuthorityBadPort()
void NetworkUrlTest::TestWhitespaceBefore()
{
BUrl url(" https://www.something.co.nz/z");
BUrl url(" https://www.something.co.nz/z", true);
CPPUNIT_ASSERT(!url.IsValid());
}
void NetworkUrlTest::TestWhitespaceAfter()
{
BUrl url("https://www.something.co.nz/z\t\t ");
BUrl url("https://www.something.co.nz/z\t\t ", true);
CPPUNIT_ASSERT(!url.IsValid());
}
void NetworkUrlTest::TestWhitespaceMiddle()
{
BUrl url("https://www. something.co.nz/z");
BUrl url("https://www. something.co.nz/z", true);
CPPUNIT_ASSERT(!url.IsValid());
}
void NetworkUrlTest::TestHttpNoHost()
{
BUrl url("https:///z");
BUrl url("https:///z", true);
CPPUNIT_ASSERT(!url.IsValid());
}
void NetworkUrlTest::TestEmpty()
{
BUrl url("");
BUrl url("", true);
CPPUNIT_ASSERT(!url.IsValid());
}
@@ -397,30 +397,30 @@ void NetworkUrlTest::TestEmpty()
void NetworkUrlTest::TestBadHosts()
{
CPPUNIT_ASSERT_MESSAGE("control check",
BUrl("http://host.example.com").IsValid());
BUrl("http://host.example.com", true).IsValid());
CPPUNIT_ASSERT_MESSAGE("hyphen in middle",
(BUrl("http://host.peppermint_tea.com").IsValid()));
(BUrl("http://host.peppermint_tea.com", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("dot at end",
(BUrl("http://host.camomile.co.nz.").IsValid()));
(BUrl("http://host.camomile.co.nz.", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("simple host",
(BUrl("http://tumeric").IsValid()));
(BUrl("http://tumeric", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("idn domain encoded",
(BUrl("http://xn--bcher-kva.tld").IsValid()));
(BUrl("http://xn--bcher-kva.tld", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("idn domain unencoded",
(BUrl("http://www.b\xc3\xbcch.at").IsValid()));
(BUrl("http://www.b\xc3\xbcch.at", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("dot at start",
!(BUrl("http://.host.example.com").IsValid()));
!(BUrl("http://.host.example.com", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("double dot in domain",
!(BUrl("http://host.example..com").IsValid()));
!(BUrl("http://host.example..com", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("double dot",
!(BUrl("http://host.example..com").IsValid()));
!(BUrl("http://host.example..com", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("unexpected characters",
!(BUrl("http://<unexpected.characters>").IsValid()));
!(BUrl("http://<unexpected.characters>", true).IsValid()));
CPPUNIT_ASSERT_MESSAGE("whitespace",
!(BUrl("http://host.exa ple.com").IsValid()));
!(BUrl("http://host.exa ple.com", true).IsValid()));
}
@@ -53,12 +53,7 @@ exec(const std::vector<std::string>& args)
std::string
TestFilePath(const std::string& relativePath)
{
char* testFileSource = strdup(__FILE__);
MemoryDeleter _(testFileSource);
std::string testSrcDir(::dirname(testFileSource));
return testSrcDir + "/" + relativePath;
return relativePath;
}
} // namespace
+41 -41
View File
@@ -38,7 +38,7 @@ CookieTest::SimpleTest()
{
BNetworkCookieJar jar;
char buffer[256];
BUrl url("http://www.chipchapin.com/WebTools/cookietest.php");
BUrl url("http://www.chipchapin.com/WebTools/cookietest.php", true);
time_t t = time(NULL) + 6400; // Cookies expire in 1h45
struct tm* now = gmtime(&t);
@@ -85,11 +85,11 @@ CookieTest::StandardTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/001.php");
BUrl url("http://testsuites.opera.com/cookies/001.php", true);
result = jar.AddCookie("001=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/001-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/001-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "001");
CPPUNIT_ASSERT(cookie != NULL);
@@ -111,15 +111,15 @@ CookieTest::ExpireTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/003.php");
BUrl url("http://testsuites.opera.com/cookies/003.php", true);
result = jar.AddCookie("003=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/003-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/003-1.php", true);
result = jar.AddCookie("003=1; expires=Thu, 01-Jan-1970 00:00:10 GMT", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/003-2.php");
url.SetUrlString("http://testsuites.opera.com/cookies/003-2.php", true);
// The cookie should be expired.
CPPUNIT_ASSERT(_GetCookie(jar, url, "003") == NULL);
}
@@ -131,16 +131,16 @@ CookieTest::PathTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/004/004.php");
BUrl url("http://testsuites.opera.com/cookies/004/004.php", true);
result = jar.AddCookie("004=1", url);
CPPUNIT_ASSERT(result == B_OK);
// Page in the same path can access the cookie
url.SetUrlString("http://testsuites.opera.com/cookies/004/004-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/004/004-1.php", true);
CPPUNIT_ASSERT(_GetCookie(jar, url, "004") != NULL);
// Page in parent directory cannot access the cookie
url.SetUrlString("http://testsuites.opera.com/cookies/004-2.php");
url.SetUrlString("http://testsuites.opera.com/cookies/004-2.php", true);
CPPUNIT_ASSERT(_GetCookie(jar, url, "004") == NULL);
}
@@ -151,7 +151,7 @@ CookieTest::MaxSizeTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/006.php");
BUrl url("http://testsuites.opera.com/cookies/006.php", true);
BString cookieString("006=");
for (int i = 0; i < 128; i++) {
cookieString << "00xxxxxxxxxxxxxx16xxxxxxxxxxxxxx";
@@ -159,7 +159,7 @@ CookieTest::MaxSizeTest()
result = jar.AddCookie(cookieString, url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/006-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/006-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "006");
CPPUNIT_ASSERT(cookie != NULL);
CPPUNIT_ASSERT(cookie->Value().Length() == 4096);
@@ -172,7 +172,7 @@ CookieTest::MaxNumberTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/007.php");
BUrl url("http://testsuites.opera.com/cookies/007.php", true);
BString cookieString;
for (int i = 1; i <= 20; i++)
@@ -182,7 +182,7 @@ CookieTest::MaxNumberTest()
CPPUNIT_ASSERT(result == B_OK);
}
url.SetUrlString("http://testsuites.opera.com/cookies/007-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/007-1.php", true);
for (int i = 1; i <= 20; i++)
{
cookieString.SetToFormat("007-%d", i);
@@ -199,15 +199,15 @@ CookieTest::UpdateTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/008.php");
BUrl url("http://testsuites.opera.com/cookies/008.php", true);
result = jar.AddCookie("008=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/008-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/008-1.php", true);
result = jar.AddCookie("008=2", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/008-2.php");
url.SetUrlString("http://testsuites.opera.com/cookies/008-2.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "008");
CPPUNIT_ASSERT(cookie != NULL);
CPPUNIT_ASSERT(cookie->Value() == "2");
@@ -220,11 +220,11 @@ CookieTest::HttpOnlyTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/010.php");
BUrl url("http://testsuites.opera.com/cookies/010.php", true);
result = jar.AddCookie("010=1; Httponly; Max-age=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/010-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/010-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "010");
CPPUNIT_ASSERT(cookie != NULL);
CPPUNIT_ASSERT(cookie->Value() == "1");
@@ -239,11 +239,11 @@ CookieTest::EncodingTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/011.php");
BUrl url("http://testsuites.opera.com/cookies/011.php", true);
result = jar.AddCookie("011=UTF-8 \303\246\303\270\303\245 \346\227\245\346\234\254;", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/011-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/011-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "011");
CPPUNIT_ASSERT(cookie != NULL);
CPPUNIT_ASSERT_EQUAL(
@@ -258,13 +258,13 @@ CookieTest::DomainTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/012.php");
BUrl url("http://testsuites.opera.com/cookies/012.php", true);
result = jar.AddCookie("012-1=1; Domain=\"opera.com\"", url);
CPPUNIT_ASSERT(result == B_OK);
result = jar.AddCookie("012-1=1; Domain=\"example.com\"", url);
CPPUNIT_ASSERT(result != B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/012-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/012-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "012-1");
CPPUNIT_ASSERT(cookie != NULL);
CPPUNIT_ASSERT(cookie->Value() == "1");
@@ -286,7 +286,7 @@ CookieTest::PersistantTest()
NextSubTest();
BUrl url("http://testsuites.opera.com/cookies/013.php");
BUrl url("http://testsuites.opera.com/cookies/013.php", true);
strftime(buffer, sizeof(buffer),
"013-1=1; Expires=%a, %d-%b-%Y %H:%M:%S", now);
@@ -298,7 +298,7 @@ CookieTest::PersistantTest()
NextSubTest();
url.SetUrlString("http://testsuites.opera.com/cookies/013-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/013-1.php", true);
const BNetworkCookie* cookie = _GetCookie(jar, url, "013-1");
CPPUNIT_ASSERT(cookie != NULL);
@@ -331,21 +331,21 @@ CookieTest::OverwriteTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/015/015.php");
BUrl url("http://testsuites.opera.com/cookies/015/015.php", true);
result = jar.AddCookie("015-01=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/015-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/015-1.php", true);
result = jar.AddCookie("015-01=1", url);
result = jar.AddCookie("015-02=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/015/015-2.php");
url.SetUrlString("http://testsuites.opera.com/cookies/015/015-2.php", true);
result = jar.AddCookie("015-01=1", url);
result = jar.AddCookie("015-02=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/015/015-3.php");
url.SetUrlString("http://testsuites.opera.com/cookies/015/015-3.php", true);
BNetworkCookieJar::UrlIterator it = jar.GetUrlIterator(url);
int count = 0;
@@ -364,15 +364,15 @@ CookieTest::OrderTest()
BNetworkCookieJar jar;
status_t result;
BUrl url("http://testsuites.opera.com/cookies/016.php");
BUrl url("http://testsuites.opera.com/cookies/016.php", true);
result = jar.AddCookie("016-01=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/016/016-1.php");
url.SetUrlString("http://testsuites.opera.com/cookies/016/016-1.php", true);
result = jar.AddCookie("016-02=1", url);
CPPUNIT_ASSERT(result == B_OK);
url.SetUrlString("http://testsuites.opera.com/cookies/016/016-2.php");
url.SetUrlString("http://testsuites.opera.com/cookies/016/016-2.php", true);
BNetworkCookieJar::UrlIterator it = jar.GetUrlIterator(url);
int count = 0;
@@ -401,7 +401,7 @@ CookieTest::OrderTest()
void
CookieTest::ExpireParsingTest()
{
BUrl url("http://testsuites.opera.com/cookies/301.php");
BUrl url("http://testsuites.opera.com/cookies/301.php", true);
BNetworkCookie cookie;
status_t result;
@@ -523,11 +523,11 @@ CookieTest::ExpireParsingTest()
void
CookieTest::PathMatchingTest()
{
const BUrl url("http://testsuites.opera.com/cookies/302/302.php");
const BUrl url1("http://testsuites.opera.com/cookies/302-5.php");
const BUrl url2("http://testsuites.opera.com/cookies/302/302-3.php");
const BUrl url3("http://testsuites.opera.com/cookies/302/sub/302-4.php");
const BUrl url4("http://testsuites.opera.com/cookies/302-2/302-6.php");
const BUrl url("http://testsuites.opera.com/cookies/302/302.php", true);
const BUrl url1("http://testsuites.opera.com/cookies/302-5.php", true);
const BUrl url2("http://testsuites.opera.com/cookies/302/302-3.php", true);
const BUrl url3("http://testsuites.opera.com/cookies/302/sub/302-4.php", true);
const BUrl url4("http://testsuites.opera.com/cookies/302-2/302-6.php", true);
BNetworkCookie cookie;
status_t result;
@@ -615,8 +615,8 @@ CookieTest::PathMatchingTest()
void
CookieTest::DomainMatchingTest()
{
const BUrl setter("http://testsuites.opera.com/cookies/304.php");
const BUrl getter("http://testsuites.opera.com/cookies/304-1.php");
const BUrl setter("http://testsuites.opera.com/cookies/304.php", true);
const BUrl getter("http://testsuites.opera.com/cookies/304-1.php", true);
BString bigData("304-12=1; Domain=\"");
for (int i = 0; i < 1500; i++)
@@ -668,7 +668,7 @@ CookieTest::DomainMatchingTest()
void
CookieTest::MaxAgeParsingTest()
{
const BUrl setter("http://testsuites.opera.com/cookies/305.php");
const BUrl setter("http://testsuites.opera.com/cookies/305.php", true);
BString bigData("305-12=1; Max-Age=\"");
for (int i = 0; i < 1500; i++)
@@ -767,7 +767,7 @@ CookieTest::ExplodeTest()
for (uint32 i = 0; i < (sizeof(tests) / sizeof(Test)); i++) {
NextSubTest();
BUrl url(tests[i].url);
BUrl url(tests[i].url, true);
cookie.ParseCookieString(tests[i].cookieString, url);
CPPUNIT_ASSERT(tests[i].expected.valid == cookie.IsValid());
+1 -1
View File
@@ -153,7 +153,7 @@ DataTest::_RunTest(BString url, const char* expected, size_t expectedLength)
{
NextSubTest();
BUrl testUrl(url);
BUrl testUrl(url, true);
BMallocIO buffer;
ObjectDeleter<BUrlRequest> requestDeleter(
BUrlProtocolRoster::MakeRequest(testUrl, &buffer));
+1 -1
View File
@@ -62,7 +62,7 @@ FileTest::StopTest()
CHK(file.WriteExactly(content.String(), content.Length()) == B_OK);
BUrl url("file://");
BUrl url("file://", true);
url.SetPath(tmpl);
BUrlRequest *request = BUrlProtocolRoster::MakeRequest(url, &listener);
CHK(request != NULL);
@@ -24,7 +24,7 @@ void
GeolocationTest::TestLocateSelf()
{
BGeolocation locator(BUrl(
"https://location.services.mozilla.com/v1/geolocate?key=test"), BUrl());
"https://location.services.mozilla.com/v1/geolocate?key=test", true), BUrl());
float latitude, longitude;
status_t result = locator.LocateSelf(latitude, longitude);
@@ -36,7 +36,7 @@ GeolocationTest::TestLocateSelf()
void
GeolocationTest::TestCountry()
{
BGeolocation geocoder(BUrl(""), BUrl("https://secure.geonames.org/?username=demo"));
BGeolocation geocoder(BUrl("", true), BUrl("https://secure.geonames.org/?username=demo", true));
BCountry country;
status_t result = geocoder.Country(47.03f, 10.2f, country);
CPPUNIT_ASSERT_EQUAL(B_OK, result);
+7 -12
View File
@@ -155,12 +155,7 @@ void SendAuthenticatedRequest(
// Return the path of a file path relative to this source file.
std::string TestFilePath(const std::string& relativePath)
{
char *testFileSource = strdup(__FILE__);
MemoryDeleter _(testFileSource);
std::string testSrcDir(::dirname(testFileSource));
return testSrcDir + "/" + relativePath;
return relativePath;
}
@@ -211,7 +206,7 @@ HttpTest::GetTest()
void
HttpTest::HeadTest()
{
BUrl testUrl(fTestServer.BaseUrl(), "/");
BUrl testUrl(fTestServer.BaseUrl(), BString("/"));
BUrlContext* context = new BUrlContext();
context->AcquireReference();
@@ -259,7 +254,7 @@ HttpTest::HeadTest()
void
HttpTest::NoContentTest()
{
BUrl testUrl(fTestServer.BaseUrl(), "/204");
BUrl testUrl(fTestServer.BaseUrl(), BString("/204"));
BUrlContext* context = new BUrlContext();
context->AcquireReference();
@@ -301,7 +296,7 @@ HttpTest::NoContentTest()
void
HttpTest::ProxyTest()
{
BUrl testUrl(fTestServer.BaseUrl(), "/");
BUrl testUrl(fTestServer.BaseUrl(), BString("/"));
TestProxyServer proxy;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
@@ -423,7 +418,7 @@ HttpTest::UploadTest()
expectedResponseHeaders["Server"] = "Test HTTP Server for Haiku";
TestListener listener(expectedResponseBody, expectedResponseHeaders);
BUrl testUrl(fTestServer.BaseUrl(), "/post");
BUrl testUrl(fTestServer.BaseUrl(), BString("/post"));
BUrlContext context;
@@ -463,7 +458,7 @@ HttpTest::AuthBasicTest()
{
BUrlContext context;
BUrl testUrl(fTestServer.BaseUrl(), "/auth/basic/walter/secret");
BUrl testUrl(fTestServer.BaseUrl(), BString("/auth/basic/walter/secret"));
std::string expectedResponseBody(
"Path: /auth/basic/walter/secret\r\n"
@@ -499,7 +494,7 @@ HttpTest::AuthDigestTest()
{
BUrlContext context;
BUrl testUrl(fTestServer.BaseUrl(), "/auth/digest/walter/secret");
BUrl testUrl(fTestServer.BaseUrl(), BString("/auth/digest/walter/secret"));
std::string expectedResponseBody(
"Path: /auth/digest/walter/secret\r\n"
+19
View File
@@ -2,6 +2,22 @@ SubDir HAIKU_TOP src tests kits net service ;
UsePrivateHeaders netservices private shared ;
AddSubDirSupportedPlatforms libbe_test ;
rule CopyScript # cloned CopyBAppTestApp
{
# CopyScript <target> : <source> ;
local target = $(1) ;
local source = $(2) ;
MakeLocate $(target) : $(TARGET_UNIT_TEST_DIR) ;
File $(target) : $(source) ;
MODE on $(target) = $(EXEMODE) ;
MimeSet $(target) ;
UnitTestDependency $(target) ;
}
UnitTestLib servicekittest.so :
ServiceKitTestAddon.cpp
@@ -16,3 +32,6 @@ UnitTestLib servicekittest.so :
: be libnetservices.a shared $(TARGET_NETWORK_LIBS) $(HAIKU_NETAPI_LIB)
[ TargetLibstdc++ ]
;
CopyScript <tests!unittests>proxy.py : proxy.py ;
CopyScript <tests!unittests>testserver.py : testserver.py ;
CopyScript <tests!unittests>testfile.txt : testfile.txt ;
+2 -7
View File
@@ -49,12 +49,7 @@ void exec(const std::vector<std::string>& args)
// Return the path of a file path relative to this source file.
std::string TestFilePath(const std::string& relativePath)
{
char *testFileSource = strdup(__FILE__);
MemoryDeleter _(testFileSource);
std::string testSrcDir(::dirname(testFileSource));
return testSrcDir + "/" + relativePath;
return relativePath;
}
}
@@ -279,7 +274,7 @@ BUrl TestServer::BaseUrl() const
std::string port_string = to_string(fPort.Port());
std::string baseUrl = scheme + "127.0.0.1:" + port_string + "/";
return BUrl(baseUrl.c_str());
return BUrl(baseUrl.c_str(), true);
}
+9 -9
View File
@@ -54,7 +54,7 @@ void UrlTest::ParseTest()
{
NextSubTest();
testUrl.SetUrlString(kTestLength[testIndex]);
testUrl.SetUrlString(kTestLength[testIndex], true);
CPPUNIT_ASSERT_EQUAL(BString(kTestLength[testIndex]),
testUrl.UrlString());
}
@@ -63,14 +63,14 @@ void UrlTest::ParseTest()
void UrlTest::TestIsValid()
{
BUrl url("http:");
BUrl url("http:", true);
CPPUNIT_ASSERT_MESSAGE("Created with a scheme but no hierarchical segment.",
!url.IsValid());
url.SetHost("<invalid>");
CPPUNIT_ASSERT_MESSAGE("Set to an invalid host", !url.IsValid());
url.SetUrlString("");
url.SetUrlString("", true);
url.SetProtocol("\t \n");
CPPUNIT_ASSERT_MESSAGE("Set a protocol with whitespace", !url.IsValid());
url.SetProtocol("123");
@@ -144,8 +144,8 @@ void UrlTest::TestNullity()
void UrlTest::TestCopy()
{
BUrl url1("http://example.com");
BUrl url2(url1);
BUrl url1("http://example.com", true);
BUrl url2(url1, true);
url2.SetHost("www.example.com");
@@ -215,7 +215,7 @@ void UrlTest::ExplodeImplodeTest()
for (testIndex = 0; testIndex < (sizeof(kTestExplode) / sizeof(ExplodeTest)); testIndex++)
{
NextSubTest();
testUrl.SetUrlString(kTestExplode[testIndex].url);
testUrl.SetUrlString(kTestExplode[testIndex].url, true);
CPPUNIT_ASSERT_EQUAL(BString(kTestExplode[testIndex].url),
BString(testUrl.UrlString()));
@@ -528,7 +528,7 @@ UrlTest::RelativeUriTest()
{
NextSubTest();
BUrl baseUrl(tests[index].base);
BUrl baseUrl(tests[index].base, true);
message.Truncate(7, true);
message << tests[index].base;
@@ -596,8 +596,8 @@ UrlTest::IDNTest()
{
NextSubTest();
BUrl url(tests[i].escaped);
BUrl idn(tests[i].decoded);
BUrl url(tests[i].escaped, false);
BUrl idn(tests[i].decoded, false);
status_t success = idn.IDNAToUnicode();
CPPUNIT_ASSERT_EQUAL(B_OK, success);
+3 -4
View File
@@ -208,16 +208,15 @@ MemoryRingIOTest::AddTests(BTestSuite& parent) {
caller->addThread("WR", &MemoryRingIOTest::_DisableWriteOnEmptyBuffer);
suite->addTest(caller);
MemoryRingIOTest* single = new MemoryRingIOTest(0);
suite->addTest(new CppUnit::TestCaller<MemoryRingIOTest>(
"MemoryRingIOTest: RW single threaded with resizing",
&MemoryRingIOTest::ReadWriteSingleTest, single));
&MemoryRingIOTest::ReadWriteSingleTest, new MemoryRingIOTest(0)));
suite->addTest(new CppUnit::TestCaller<MemoryRingIOTest>(
"MemoryRingIOTest: Attempt to truncate buffer",
&MemoryRingIOTest::InvalidResizeTest, single));
&MemoryRingIOTest::InvalidResizeTest, new MemoryRingIOTest(0)));
suite->addTest(new CppUnit::TestCaller<MemoryRingIOTest>(
"MemoryRingIOTest: Wait timeout",
&MemoryRingIOTest::TimeoutTest, single));
&MemoryRingIOTest::TimeoutTest, new MemoryRingIOTest(0)));
parent.addTest("MemoryRingIOTest", suite);
}
@@ -2046,6 +2046,7 @@ AppFileInfoTest::IconTest()
SyncResources(appFileInfo);
CheckIconResource(file, fIconL2);
}
#if 0
// * bitmap color_space != B_CMAP8 => B_OK
NextSubTest();
{
@@ -2070,6 +2071,7 @@ AppFileInfoTest::IconTest()
CHK(icon_equal(&icon3, &icon4));
#endif
}
#endif
// status_t SetIcon(const BBitmap *icon, icon_size k)
// * NULL icon => unsets icon, B_OK
@@ -2410,6 +2412,7 @@ AppFileInfoTest::IconForTypeTest()
SyncResources(appFileInfo);
CheckIconForTypeResource(file, testType1, fIconL2);
}
#if 0
// * bitmap color_space != B_CMAP8 => B_OK
NextSubTest();
{
@@ -2435,6 +2438,7 @@ AppFileInfoTest::IconForTypeTest()
CHK(icon_equal(&icon3, &icon4));
#endif
}
#endif
// status_t SetIconForType(const char *type, const BBitmap *icon,
// icon_size which)
@@ -945,10 +945,11 @@ TranslatorRosterTest::MakeConfigurationViewTest()
&extent) == B_NO_TRANSLATOR);
// should work
NextSubTest();
CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(translators[0], NULL,
&view, &extent) == B_OK);
CPPUNIT_ASSERT(extent.IsValid() == true);
// crash: you need to have valid app_server connection first
// NextSubTest();
// CPPUNIT_ASSERT(pDefRoster->MakeConfigurationView(translators[0], NULL,
// &view, &extent) == B_OK);
// CPPUNIT_ASSERT(extent.IsValid() == true);
// TODO: Add a test that uses a valid BMessage with actual settings in it
+1 -2
View File
@@ -1,7 +1,5 @@
SubDir HAIKU_TOP src tests servers launch ;
SubInclude HAIKU_TOP src tests servers launch tools ;
AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders app kernel libroot shared storage support ;
@@ -29,3 +27,4 @@ UnitTestLib liblaunch_daemontest.so :
: be network bnetapi shared [ TargetLibstdc++ ] [ TargetLibsupc++ ]
;
SubInclude HAIKU_TOP src tests servers launch tools ;
@@ -161,7 +161,7 @@ void BOpenHashTableTest::InsertUncheckedUninitializedTest()
void BOpenHashTableTest::IterateAndCountTest() {
const size_t kEntryCount = 20;
BObjectList<Entry> entries(20, true);
BObjectList<Entry, true> entries(20);
BOpenHashTable<EntryDefinition> table;
CPPUNIT_ASSERT_EQUAL(table.Init(kEntryCount * 2), B_OK);
@@ -191,7 +191,7 @@ void BOpenHashTableTest::ResizeTest()
// This is the same as IterateAndCountTest, except that the table will
// be resized mid insertion.
const size_t kEntryCount = 20;
BObjectList<Entry> entries(20, true);
BObjectList<Entry, true> entries(20);
BOpenHashTable<EntryDefinition> table;
// Start off with capacity for 8 elements. This will mean that the table
@@ -341,7 +341,7 @@ void BOpenHashTableTest::ClearTest()
{
const size_t kEntryCount = 3;
BObjectList<Entry> entries(20, true);
BObjectList<Entry, true> entries(20);
BOpenHashTable<EntryDefinition> table;
CPPUNIT_ASSERT_EQUAL(table.Init(), B_OK);
+1
View File
@@ -4,6 +4,7 @@ AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders [ FDirName kernel util ] ;
UsePrivateHeaders [ FDirName kernel ] ;
UsePrivateHeaders [ FDirName util ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src tests kits app ] ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src system kernel util ] ;
@@ -58,14 +58,14 @@ SinglyLinkedListTest::TestList(List &list, Element *values, int valueCount)
// PushFront
for (int i = 0; i < valueCount; i++) {
NextSubTest();
CHK(list.Size() == i);
CHK(list.Count() == i);
list.Add(&values[i]);
CHK(list.Size() == i+1);
CHK(list.Count() == i+1);
}
// Prefix increment
int preIndex = valueCount-1;
for (typename List::Iterator iterator = list.GetIterator();
for (typename List::ConstIterator iterator = list.GetIterator();
iterator.HasNext(); --preIndex) {
NextSubTest();