예제 #1
0
	void operator()()
	{
		EXPECT_FALSE(tls->HasValue());
		tls->SetValue(autonew String("thread"));
		EXPECT_TRUE(tls->HasValue());
		EXPECT_EQ("thread", *tls->GetValue());
	}
예제 #2
0
	void operator()()
	{
		EXPECT_FALSE(tls->HasValue());
		tls->SetValue("thread");
		EXPECT_TRUE(tls->HasValue());
		EXPECT_EQ("thread", tls->GetValue());
	}
예제 #3
0
void TestKeyOperations::testParsing()
{
	AutoPointer<IObjectImage> image = 
		wfs->LoadObject("license1.lic");
	AutoPointer<ILicenseKey> key =  
		licensing->ParseLicenseKey(image->GetObjectImage(), image->GetObjectSize());
}
예제 #4
0
 ReadStream::ReadStream( const AutoPointer & value ): _cfObject( NULL )
 {
     if( value.IsValid() && value.GetTypeID() == this->GetTypeID() )
     {
         this->_cfObject = static_cast< CFReadStreamRef >( const_cast< void * >( CFRetain( value ) ) );
     }
 }
예제 #5
0
 String::String( const AutoPointer & value ): _cfObject( nullptr )
 {
     if( value.IsValid() && value.GetTypeID() == this->GetTypeID() )
     {
         this->_cfObject = static_cast< CFStringRef >( const_cast< void * >( CFRetain( value ) ) );
     }
 }
예제 #6
0
Directory Settings::GetAppDataDir()
{
    Directory result;
    AutoPointer<Directory> userDataDir = Directory::UserApplicationDataDirectory();
    if (userDataDir)
        result.SetLocation(Uri(userDataDir->Location().OriginalString() + "/" + m_PImpl->m_Organisation + "/" + m_PImpl->m_Application));
    return result;
}
예제 #7
0
TEST_F(BricksAudioMidiTest, VerifyTrackNames) {
	MidiReader reader(fileStream);
	for (int track = 0; !reader.EndOfFile(); reader.NextTrack(), track++) {
		while (!reader.EndOfTrack()) {
			AutoPointer<MidiEvent> event = reader.ReadEvent();
			if (event->GetType() == MidiEventType::TrackName && track > 0) // Track 0's track name is the MIDI file name
				EXPECT_EQ(String::Format("TRACK %d NAME", track), CastTo<MidiTextEvent>(event)->GetString()) << "Track name did not match";
		}
	}
}
예제 #8
0
 String::String( const AutoPointer & value, std::string defaultValueIfNULL, CFStringEncoding encoding ): _cfObject( nullptr )
 {
     if( value.IsValid() && value.GetTypeID() == this->GetTypeID() )
     {
         this->_cfObject = static_cast< CFStringRef >( const_cast< void * >( CFRetain( value ) ) );
     }
     else
     {
         this->SetValue( defaultValueIfNULL, encoding );
     }
 }
예제 #9
0
TEST(BricksThreadingThreadTest, TaskAsync) {
	AutoMonitor<Value> monitor = autonew Value((s32)0);

	AutoPointer<TaskQueue> queue = autonew TaskQueue(3); // 3 threads
	for (int i = 0; i < 10; i++)
		queue->PushTask(autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor)));

	queue->Start();

	queue->Stop(true); // Waits for queue to finish
	EXPECT_EQ(1000, monitor->GetInt32Value());
}
예제 #10
0
void TestKeyOperations::testUninstall()
{
	LicenseKeyInfo::SerialNumber sn = { 0 };
	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license5.lic");
		const ILicenseKey& key =
			utility->InstallLicenseKey("license5.key", image->GetObjectImage(), image->GetObjectSize());
		sn = key.GetKeyInfo().serial_number;
	}

	utility->UninstallLicenseKey(sn);
}
예제 #11
0
TEST_F(BricksAudioMidiTest, VerifyTrackNotes) {
	MidiReader reader(fileStream);
	for (int track = 0; !reader.EndOfFile(); reader.NextTrack(), track++) {
		int noteCount = 0;
		while (!reader.EndOfTrack()) {
			AutoPointer<MidiEvent> event = reader.ReadEvent();
			if (event->GetType() == MidiEventType::NoteOn) {
				EXPECT_EQ(track, CastTo<MidiNoteEvent>(event)->GetNote()) << "Track note value did not match";
				noteCount++;
			}
		}
		if (track > 0) // Track 0 has no notes, just tempo data
			EXPECT_EQ(4, noteCount) << "Unexpected note count";
	}
}
예제 #12
0
void TestKeyOperations::testInstallInvalidSignature()
{
	AutoPointer<IObjectImage> image = wfs->LoadObject("license1.xml");
	try
	{
		utility->InstallLicenseKey("license1.xml", image->GetObjectImage(), image->GetObjectSize());
	}
	catch(ILicensingError& e)
	{
		CPPUNIT_ASSERT(e.GetErrorCode() == ILicensingError::LICERR_INVALID_SIGNATURE);
		return;
	}
	
	CPPUNIT_FAIL("Key with ivalid signature can not be installed");
}
예제 #13
0
void *putManyObj(char *serializedIn)
{
    AutoData<List> inArgs((List *)deserialize((const char *)serializedIn));
    if(inArgs->clazz != CLASS_APD)// || inArgs->dtype != DTYPE_LIST)
        throw MdsException("INTERNAL ERROR: Get Multi did not receive a LIST argument");

    int nArgs = inArgs->len();
    String nodeKey("node");
    String exprKey("exp");
    String argsKey("args");
    AutoData<Dictionary> result(new Dictionary());
    for(int idx = 0; idx < nArgs; idx++) {
        AutoData<Dictionary> currArg((Dictionary *)inArgs->getElementAt(idx));
        if(currArg->clazz != CLASS_APD)// || currArg->dtype != DTYPE_DICTIONARY)
            throw MdsException("INTERNAL ERROR: Get Multi Argument is not a DICTIONARY argument");

        AutoData<String> nodeNameData((String *)currArg->getItem(&nodeKey));
        AutoData<String> exprData((String *)currArg->getItem(&exprKey));
        AutoArray<char> expr(exprData->getString());
        AutoData<List> argsData((List *)currArg->getItem(&argsKey));

        int nPutArgs = 0;
        if(argsData.get())
            nPutArgs = argsData->len();

        try {
            AutoPointer<Tree> tree(getActiveTree());
            AutoData<Data> compiledData = (Data *)compileFromExprWithArgs(expr.get(), nPutArgs, (argsData.get())?argsData->getDscs():0, tree.get());
            AutoPointer<TreeNode> node = tree->getNode(nodeNameData.get());
            node->putData(compiledData.get());
            AutoData<String> successData(new String("Success"));
            result->setItem(nodeNameData.get(), successData.get());
        } catch(MdsException const & e) {
            AutoData<String> errorData(new String(e.what()));
            result->setItem(nodeNameData.get(), errorData.get());
        }
    }

    return result->convertToDsc();
}
예제 #14
0
void TestKeyOperations::testGetByContext()
{
	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license8.lic");
		utility->InstallLicenseKey("license8.key", image->GetObjectImage(), image->GetObjectSize());
	}

	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license9.lic");
		utility->InstallLicenseKey("license9.key", image->GetObjectImage(), image->GetObjectSize());
	}

	// context from second license key (license9)
	LicenseObjectId id1 = {1300, LicenseObjectId::OBJ_TYPE_APPLICATION, 6, 0 };
	LicenseContext context;
	context.AddItem(id1);
	utility = licensing->MakeLicenseUtility(context);
	ILicenseUtility::KeyEnumerator ke = utility->GetInstalledKeys();
	CPPUNIT_ASSERT_MESSAGE("License license9.key is not included", !ke.IsDone());
	
	ILicenseObject::LicenseObjectEnumerator le = ke.Item().GetLicenseObject().GetLicenseObjects();
	CPPUNIT_ASSERT(!le.IsDone());
	for (; le.IsDone(); le.Next())
	{
		if (le.Item().GetObjectId().id == id1.id)
			break;
	}
	// license object is found
	CPPUNIT_ASSERT_MESSAGE("License object with id 1330 is not found", !le.IsDone());

	// wrong context
	LicenseObjectId id2 = {999, LicenseObjectId::OBJ_TYPE_APPLICATION, 6, 0 };
	context.AddItem(id2);
	utility = licensing->MakeLicenseUtility(context);

	ke = utility->GetInstalledKeys();
	CPPUNIT_ASSERT_MESSAGE("Installed key list must be empty", ke.IsDone());

	// root context
	context.Clear();
	utility = licensing->MakeLicenseUtility(context);
	ke = utility->GetInstalledKeys();
	CPPUNIT_ASSERT_MESSAGE("Installed key list must not be empty", !ke.IsDone());
	// first key (license8)
	CPPUNIT_ASSERT(ke.Item().GetKeyInfo().serial_number.sequence_number == 21);
	ke.Next();
	CPPUNIT_ASSERT_MESSAGE("Installed key list must not be empty", !ke.IsDone());
	// first key (license9)
	CPPUNIT_ASSERT(ke.Item().GetKeyInfo().serial_number.sequence_number == 22);
	ke.Next();
	CPPUNIT_ASSERT_MESSAGE("More than two keys (license8, license9) returned", ke.IsDone());
}
예제 #15
0
TEST(BricksThreadingThreadTest, TaskSync) {
	AutoMonitor<Value> monitor = autonew Value((s32)0);

	AutoPointer<TaskQueue> queue = autonew TaskQueue(1); // 1 thread, serial queue

	for (int i = 0; i < 3; i++)
		queue->PushTask(autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor, i * 100)));

	AutoPointer<Task<int> > task = autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor, 300));
	queue->PushTask(task);

	queue->Start();

	EXPECT_EQ(400, task->Wait());
}
예제 #16
0
void TestKeyOperations::testInstallWithSameSerial()
{
	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license2.lic");
		utility->InstallLicenseKey("license2.key", image->GetObjectImage(), image->GetObjectSize());
	}

	try
	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license3.lic");
		utility->InstallLicenseKey("license3.key", image->GetObjectImage(), image->GetObjectSize());
	}
	catch(ILicensingError& e)
	{
		CPPUNIT_ASSERT(e.GetErrorCode() == ILicensingError::LICERR_DUPLICATE_KEY);
		return;
	}

	CPPUNIT_FAIL("Keys with identical SN can not be installed");
}
예제 #17
0
파일: main.cpp 프로젝트: AerialX/libbricks
	FileStream* stream = new FileStream("/tmp/libbricks-test.bin", FileOpenMode::Create, FileMode::WriteOnly, FilePermissions::OwnerReadWrite);

	StreamWriter* writer = new StreamWriter(stream, Endian::BigEndian);
	writer->WriteInt32(0x1337BAAD);
	writer->WriteString("ohai");
	writer->WriteByte('\0');
	writer->WriteInt16(0xF33D, Endian::LittleEndian);

	// Manually delete these objects from memory.
	writer->Release();
	stream->Release();

	Console::GetDefault()->Out->WriteLine("Reading test file...");

	AutoPointer<FileStream> rstream = autonew FileStream("/tmp/libbricks-test.bin", FileOpenMode::Open, FileMode::ReadOnly);
	AutoPointer<StreamReader> reader = autonew StreamReader(rstream, Endian::LittleEndian);
	u32 num = reader->ReadInt32(Endian::BigEndian);
	BRICKS_FEATURE_ASSERT(num == 0x1337BAAD);
	String str = reader->ReadString();
	BRICKS_FEATURE_ASSERT(str == "ohai");
	u16 num2 = reader->ReadInt16();
	BRICKS_FEATURE_ASSERT(num2 == 0xF33D);
	BRICKS_FEATURE_ASSERT(reader->IsEndOfFile()); // Not implemented yet, fail.
	rstream.Release();

	Console::GetDefault()->Out->WriteLine(String::Format("Success! Read back 0x%08x, \"%s\", and 0x%04x from file.", num, str.CString(), num2));

	// rstream and reader are both Released() when this returns thanks to AutoPointer.

	Console::GetDefault()->Out->WriteLine(" --- File Path Test --- ");
	Console::GetDefault()->Out->WriteLine("Creating FilePath, should be /test/lol/sup");
예제 #18
0
void TestKeyOperations::testWrongAppVersionType()
{
	// test release key for beta product
	{
		ProgramClientInfo pci = 
		{
			{ { 666, LicenseObjectId::OBJ_TYPE_PRODUCT, 6, 0 }, 1, 1, 1, 1 },
			ProgramClientInfo::VER_TYPE_BETA,
			PT_WIN_PERSONAL
		};

		LicenseContext context;
		AutoPointer<ILicensing> licensing = MakeLicensing(*wfs, pci, "..\\..\\..\\data");
		AutoPointer<IObjectImage> image = wfs->LoadObject("license5.lic");
		AutoPointer<ILicenseKey> key = licensing->ParseLicenseKey(image->GetObjectImage(), image->GetObjectSize());
		AutoPointer<ILicenseUtility> utility = licensing->MakeLicenseUtility(context);
		CPPUNIT_ASSERT(utility->GetLicenseKeyStatus(*key) == ILicenseUtility::KEY_INCOMPATIBLE_VERSION_TYPE);
	}

	// test beta key for release product
	try
	{
		AutoPointer<IObjectImage> image = wfs->LoadObject("license4.lic");
		AutoPointer<ILicenseKey> key = licensing->ParseLicenseKey(image->GetObjectImage(), image->GetObjectSize());
		CPPUNIT_ASSERT(utility->GetLicenseKeyStatus(*key) == ILicenseUtility::KEY_INCOMPATIBLE_VERSION_TYPE);
		utility->InstallLicenseKey("license4.key", image->GetObjectImage(), image->GetObjectSize());
	}
	catch(ILicensingError& e)
	{
		CPPUNIT_ASSERT(e.GetErrorCode() == ILicensingError::LICERR_KEY_MISMATCH);
		return;
	}

	CPPUNIT_FAIL("Keys with incompatible version type can not be installed");
}