static void TestBitmapFactory(skiatest::Reporter* reporter) {
    SkAutoTDelete<SkBitmap> bitmap(create_bitmap());
    SkASSERT(bitmap.get() != NULL);

    SkAutoDataUnref encodedBitmap(create_data_from_bitmap(*bitmap.get()));
    bool encodeSucceeded = encodedBitmap.get() != NULL;
    SkASSERT(encodeSucceeded);

    ImageCacheHolder cacheHolder;

    SkAutoTUnref<SkLruImageCache> lruCache(SkNEW_ARGS(SkLruImageCache, (1024 * 1024)));
    cacheHolder.addImageCache(lruCache);

    cacheHolder.addImageCache(NULL);

    SkImageCache* purgeableCache = SkPurgeableImageCache::Create();
    if (purgeableCache != NULL) {
        cacheHolder.addImageCache(purgeableCache);
        purgeableCache->unref();
    }

    for (int i = 0; i < cacheHolder.count(); i++) {
        SkImageCache* cache = cacheHolder.getAt(i);
        if (cache != NULL) {
            test_cache(reporter, cache);
        }
        if (encodeSucceeded) {
            test_factory(reporter, cache, encodedBitmap, *bitmap.get());
        }
    }
}
Example #2
0
	bool TestManager::executeTest(UnitTestCreationInfo ti, const std::string & full_test_desc)
	{
		bool test_result = false;
		
		detail::UnitTestFactoryFunction test_factory = ti->factory;
		UnitTest * unit_test = test_factory ? test_factory() : nullptr;
		
		if (unit_test != nullptr) {
			std::string begin_message = full_test_desc + " ::: START";
			logMessage(begin_message);
			
			// Set indentation and run test
			tl().setIndentationLevel(2);
			PerformanceTimer timer;
			double elapsed_time = 0.0;
			
			try {
				test_result = unit_test->runTest(this, &_test_log);
				elapsed_time = timer.elapsedTime();
			} catch (std::exception & exc) {
				std::string message("FAILED: Exception: ");
				message.append(exc.what());
				logMessage(message);
				test_result = false;
			} catch (...) {
				logMessage(std::string("FAILED: An unknown exception occured."));
				test_result = false;
			}
			
			// Clear indentation & dump result
			tl().setIndentationLevel(0);
			
			std::string end_message = full_test_desc;
			if (test_result) {
				end_message += " ::: OK ::: " + PerformanceTimer::humanReadableTime(elapsed_time);
			} else {
				end_message += " ::: FAILED";
			}
			logMessage(end_message);
			logSeparator();
			
			// destroy unit test object
			delete unit_test;
		} else {
			CC7_ASSERT(false, "Unable to create '%s'", full_test_desc.c_str());
		}
		
		return test_result;
	}
Example #3
0
int main( int argc, char **argv )
{
	phobos::system::qt4::base test_factory( argc, argv );
	
	fcppt::io::stringstream input( event );
	phobos::primitives::widget w( phobos::primitives::compile( input ) );

	phobos::system::window_ptr win(
		test_factory.create(
			phobos::system::window_parameters()
				.type(
					phobos::system::window_type::managed)
				.size(
					phobos::dim(400, 400))
				.root(
					w)));

	presenter p( w );

	win->root( w );

	return test_factory.run();
}