示例#1
0
HTREEITEM DlgSettingsMain::AddDialogToTree(const wstring& strName, const std::shared_ptr<DlgSettingsBase>& newDlg, CRect& rect, HTREEITEM htiParent /*= NULL*/)
{
	newDlg->Create(m_hWnd, rect);
	newDlg->SetWindowPos(HWND_TOP, rect.left, rect.top, 0, 0, SWP_NOSIZE);

	HTREEITEM hItem = m_treeCtrl.InsertItem(strName.c_str(), htiParent, NULL);

	if (hItem != NULL) m_settingsDlgMap.insert(SettingsDlgsMap::value_type(hItem, newDlg));

	return hItem;
}
示例#2
0
文件: task.cpp 项目: presto53/porto
TError TTask::CreateTmpDir(const TPath &path, std::shared_ptr<TFolder> &dir) const {
    bool cleanup = path.ToString().find(config().container().tmp_dir()) == 0;

    dir = std::make_shared<TFolder>(path, cleanup);
    if (!dir->Exists()) {
        TError error = dir->Create(0755, true);
        if (error)
            return error;
        error = path.Chown(Env->Cred.Uid, Env->Cred.Gid);
        if (error)
            return error;
    }

    return TError::Success();
}
示例#3
0
 cmd::CommandPtr Create(ftp::Client& client, const std::string& argStr,
                        const Args& args) const
 {
   if (!creator) return nullptr;
   return cmd::CommandPtr(creator->Create(client, argStr, args));
 }
示例#4
0
    void VerifyEffectRealizationInputs(
        std::shared_ptr<CanvasDrawingSessionManager> const& drawingSessionManager,
        TestEffect* testEffect)
    {
        ComPtr<StubD2DDevice> stubDevice = Make<StubD2DDevice>();
        ComPtr<StubD2DDeviceContextWithGetFactory> deviceContext = Make<StubD2DDeviceContextWithGetFactory>();

        deviceContext->GetDeviceMethod.AllowAnyCallAlwaysCopyValueToParam(stubDevice);
        deviceContext->DrawImageMethod.AllowAnyCall();

        bool setInputCalled = false;
        bool setInputCountCalled = false;
        bool setValueCalled = false;

        deviceContext->CreateEffectMethod.SetExpectedCalls(1,
            [&](IID const&, ID2D1Effect** effect)
            {
                ComPtr<MockD2DEffect> mockEffect = Make<MockD2DEffect>();
                mockEffect.CopyTo(effect);

                mockEffect->MockSetInput =
                    [&]
                    {
                        Assert::IsFalse(setInputCalled);
                        setInputCalled = true;
                    };

                mockEffect->MockSetInputCount =
                    [&]
                    {
                        Assert::IsFalse(setInputCountCalled);
                        setInputCountCalled = true;
                        return S_OK;
                    };

                mockEffect->MockSetValue =
                    [&]
                    {
                        Assert::IsFalse(setValueCalled);
                        setValueCalled = true;
                        return S_OK;
                    };

                return S_OK;
            });

        auto drawingSession = drawingSessionManager->Create(deviceContext.Get(), std::make_shared<StubCanvasDrawingSessionAdapter>());

        Vector2 position = { 0, 0 };
        drawingSession->DrawImage(testEffect, position);

        Assert::IsTrue(setInputCalled);
        Assert::IsTrue(setInputCountCalled);
        Assert::IsTrue(setValueCalled);

        // Drawing on a second device context that shares the same device should NOT rerealize the effect.
        ComPtr<StubD2DDeviceContextWithGetFactory> deviceContext2 = Make<StubD2DDeviceContextWithGetFactory>();

        deviceContext2->GetDeviceMethod.AllowAnyCallAlwaysCopyValueToParam(stubDevice);
        deviceContext2->DrawImageMethod.AllowAnyCall();
        deviceContext2->CreateEffectMethod.SetExpectedCalls(0);

        auto drawingSession2 = drawingSessionManager->Create(deviceContext2.Get(), std::make_shared<StubCanvasDrawingSessionAdapter>());

        drawingSession2->DrawImage(testEffect, position);
    }