コード例 #1
0
void ComponentsUnitTests::testExecNoCallback()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
    Assert::IsTrue(! DVLib::FileExists(check_file));
    component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
    components.add(ComponentPtr(component1));
    components.Exec(NULL);
    Assert::IsTrue(DVLib::FileExists(check_file));
    DVLib::FileDelete(check_file);
}
コード例 #2
0
void ComponentsUnitTests::testExecWithError()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    component1->command = L"foobar.exe";
    components.add(ComponentPtr(component1));
    ExecuteComponentCallbackImpl callback;
    components.Exec(& callback);
    Assert::IsTrue(1 == callback.starts);
    Assert::IsTrue(1 == callback.begins);
    Assert::IsTrue(0 == callback.waits);
    Assert::IsTrue(0 == callback.successes);
    Assert::IsTrue(1 == callback.errors);
}
コード例 #3
0
int InstallerWindow::ExecOnThread()
{
	try
	{
		auto_any<htmlayout::dom::element *, html_disabled> btn_install(& button_install);
		htmlayout::queue::push(new html_set_attribute_task(& button_install, "disabled", L"disabled"), HtmlWindow::s_hwnd);
		auto_any<htmlayout::dom::element *, html_disabled> btn_skip(& button_skip);
		htmlayout::queue::push(new html_set_attribute_task(& button_skip, "disabled", L"disabled"), HtmlWindow::s_hwnd);

		ClearError();
		ClearProgress();

		InstallConfiguration * p_configuration = reinterpret_cast<InstallConfiguration *>(get(m_configuration));
		CHECK_BOOL(p_configuration != NULL, L"Invalid configuration");

		if (RestartElevated())
		{
			OnCancel();
			return 0;
		}

		Components components = p_configuration->GetSupportedComponents(
			InstallerSession::Instance->lcidtype, InstallerSession::Instance->sequence);

		SetProgressTotal(components.size() * 2);

		int rc = components.Exec(this);
		InstallerUI::AfterInstall(rc);
		return 0;
    }
    catch(std::exception& ex)
    {
		LOG(L"*** Failed to install one or more components: " << DVLib::string2wstring(ex.what()));
		ShowError(DVLib::string2wstring(ex.what()));
		RecordError();
    }
	catch(...)
	{
		LOG(L"*** Failed to install one or more components");
		ShowError(TEXT("Failed to install one or more components"));
		RecordError();
	}

	return 0;
}
コード例 #4
0
void ComponentsUnitTests::testExecWithCallback()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
    Assert::IsTrue(! DVLib::FileExists(check_file));
    component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
    components.add(ComponentPtr(component1));
    ExecuteComponentCallbackImpl callback;
    components.Exec(& callback);
    Assert::IsTrue(DVLib::FileExists(check_file));
    DVLib::FileDelete(check_file);
    Assert::IsTrue(1 == callback.starts);
    Assert::IsTrue(1 == callback.begins);
    Assert::IsTrue(1 == callback.waits);
    Assert::IsTrue(1 == callback.successes);
    Assert::IsTrue(0 == callback.errors);
}