Exemplo n.º 1
0
  static void TestDirectOverlay(char *in, char *gt, const int lower, const int upper)
  {
    mitk::Image::Pointer original = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(in)[0].GetPointer());
    mitk::Image::Pointer truth = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(gt)[0].GetPointer());

    if (original.IsNotNull() && original->GetDimension() == 3 && truth.IsNotNull() && truth->GetDimension() == 3 &&
        upper > lower)
    {
      TestOverlay(original, truth, lower, upper);
    }
    else
    {
      MITK_TEST_FAILED_MSG(<< "Invalid parameters");
    }
  }
Exemplo n.º 2
0
HRESULT ViewTest2::Run()
{
	// Make a special VwGraphics (#define BASELINE in compiling it turns on special features).
	// This VwGraphics will not draw (2nd arg false) but will record attempts at drawing into
	// the baseline.
	m_psts = NewObj SilTestSite();
	m_qst.Attach(m_psts);
	m_qvg.Attach(NewObj VwGraphics(m_psts, false, true));
	m_qst->SetBaselineFile(SmartBstr(L"c:\\fw\\testlog\\log\\VwGraphics").Bstr());

	// Todo LukeU(JohnT): make an off-screen bitmap HDC and initialize the VwGraphics to use it.
	// Here is your off-screen bitmap and memory surface
	HDC hdcScr, hdcMem;
	hdcScr = GetDC(NULL);
	hdcMem = CreateCompatibleDC(hdcScr);
	HBITMAP hBitmap = CreateCompatibleBitmap(hdcMem, 400, 400);
	SelectObject(hdcMem, hBitmap);
	ReleaseDC(NULL, hdcScr);

	m_qvg->Initialize(hdcMem);

	// Make a dummy root site for the Root box to talk back to
	m_qtrs.Attach(NewObj VwTestRootSite);
	m_qtrs->SetVgObject(m_qvg);
	Rect rcSrc(0, 0, 96, 96);
	Rect rcDst(0, 0, 96, 96);
	m_qtrs->SetSrcRoot(rcSrc);
	m_qtrs->SetDstRoot(rcDst);

	// Make our view constructor.
	m_qtvc.Attach(NewObj TestStVc);

	// Put some dummy data into a cache. HVO 1 identifies the text as a whole.
	// Arbitrarily objects 2, 3, and 4 are the three paragraphs of our test data.
	m_qda.Attach(NewObj VwCacheDa);

	HVO rghvoPara[3] = {2, 3, 4};
	m_qda->CacheVecProp(1, kflidStText_Paragraphs, rghvoPara, 3);

	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);

	ITsStringPtr qtss;
	int enc = 100;

	StrUni stuPara0 = L"This is the first paragraph";
	StrUni stuPara1 = L"Here is another paragraph, quite silly and trivial but it should "
						L"help test things";
	StrUni stuPara2 = L"I try to keep the text in these quite different so they can't be "
						L"confused";

	CheckHr(qtsf->MakeStringRgch(stuPara0.Chars(), stuPara0.Length(), enc, &qtss));
	m_qda->CacheStringProp(rghvoPara[0], kflidStTxtPara_Contents, qtss);

	CheckHr(qtsf->MakeStringRgch(stuPara1.Chars(), stuPara1.Length(), enc, &qtss));
	m_qda->CacheStringProp(rghvoPara[1], kflidStTxtPara_Contents, qtss);

	CheckHr(qtsf->MakeStringRgch(stuPara2.Chars(), stuPara2.Length(), enc, &qtss));
	m_qda->CacheStringProp(rghvoPara[2], kflidStTxtPara_Contents, qtss);

	ITsPropsBldrPtr qtpb;
	qtpb.CreateInstance(CLSID_TsPropsBldr);
	StrUni stuNormal = L"Normal";
	CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));

	// Make the root box and initialize it.
	m_qrootb.CreateInstance(CLSID_VwRootBox);

	// OK, we have a root box set up. Now we can try some tests on it!
	TestInit();
	TestDataAccess();
	TestLayout(350);

	TestDrawRoot();
	TestOverlay();

	TestMakeSimpleSel();
	TestMakeTextSelection();

	TestKeys();
	TestMouse();

	Testget_Site();
	TestLoseFocus();
	TestListener();

	m_qrootb->Close();
	m_qrootb.Clear();
	m_qda.Clear();

	DeleteDC(hdcMem);
	DeleteObject(hBitmap);
	return S_OK;
}