コード例 #1
0
bool BundleResource::operator ==(const BundleResource& resource) const
{
  if (!this->IsValid()) return !resource.IsValid();
  if (!resource.IsValid()) return false;
  return d->archive->GetResourceContainer() == resource.d->archive->GetResourceContainer() &&
      d->archive->GetResourcePrefix() == resource.d->archive->GetResourcePrefix() &&
      this->GetResourcePath() == resource.GetResourcePath();
}
コード例 #2
0
int BundleResourceTest(int /*argc*/, char* /*argv*/ [])
{
  US_TEST_BEGIN("BundleResourceTest");

  FrameworkFactory factory;
  auto framework = factory.NewFramework();
  framework.Start();

  auto context = framework.GetBundleContext();
  assert(context);

  auto bundleR = testing::InstallLib(context, "TestBundleR");
  US_TEST_CONDITION_REQUIRED(bundleR &&
                               bundleR.GetSymbolicName() == "TestBundleR",
                             "Test for existing bundle TestBundleR")

  testInvalidResource(bundleR);

  Bundle executableBundle;
  try {
    executableBundle = testing::GetBundle("main", context);
    US_TEST_CONDITION_REQUIRED(executableBundle,
                               "Test installation of bundle main")
  } catch (const std::exception& e) {
    US_TEST_FAILED_MSG(<< "Install bundle exception: " << e.what())
  }

  testResourceFromExecutable(executableBundle);

  testResourceTree(bundleR);

  testResourceOperators(bundleR);

  testTextResource(bundleR);
  testTextResourceAsBinary(bundleR);
  testSpecialCharacters(bundleR);

  testBinaryResource(bundleR);

  testCompressedResource(bundleR);

  BundleResource foo = bundleR.GetResource("foo.txt");
  US_TEST_CONDITION(foo.IsValid() == true, "Valid resource")

  testResourcesFrom("TestBundleRL", framework.GetBundleContext());
  testResourcesFrom("TestBundleRA", framework.GetBundleContext());

  US_TEST_END()
}