Ejemplo n.º 1
0
void ItemContainerTestCase::SetSelection()
{
    wxItemContainer * const container = GetContainer();

    container->Append("first");
    container->Append("second");

    // This class is used to check that SetSelection() doesn't generate any
    // events, as documented.
    class CommandEventHandler : public wxEvtHandler
    {
    public:
        virtual bool ProcessEvent(wxEvent& event)
        {
            CPPUNIT_ASSERT_MESSAGE
            (
                "unexpected command event from SetSelection",
                !event.IsCommandEvent()
            );

            return wxEvtHandler::ProcessEvent(event);
        }
    } h;

    wxWindow * const win = GetContainerWindow();
    win->PushEventHandler(&h);
    wxON_BLOCK_EXIT_OBJ1( *win, wxWindow::PopEventHandler, false );

    container->SetSelection(0);
    CPPUNIT_ASSERT_EQUAL( 0, container->GetSelection() );

    container->SetSelection(1);
    CPPUNIT_ASSERT_EQUAL( 1, container->GetSelection() );
}
Ejemplo n.º 2
0
void GraphicsContextDrawingTestCase::RunIndividualDrawingCase (
    DrawingTestGCFactory& gcFactory,
    const DrawingTestCase & testCase)
{
    wxFileName fileName, refFileName;
    wxString testsOutputDirectory = wxStandardPaths::Get().GetTempDir();
    wxString refOutputDirectory = GetTestsReferenceDirectory();

    wxString platformTag;
    if (!testCase.platformIndependent && !gcFactory.PlatformIndependent())
        platformTag = wxString::Format("_%s", GetPlatformTag());

    fileName.Assign (testsOutputDirectory,
        wxString::Format("image_test_%s%s_%d", gcFactory.GetIdForFileName(),
                         platformTag, testCase.caseNumber),
        gcFactory.GetExtensionForFileName());

    refFileName.Assign (refOutputDirectory,
        wxString::Format("image_test_%s%s_%d_ref", gcFactory.GetIdForFileName(),
                        platformTag, testCase.caseNumber),
        gcFactory.GetExtensionForFileName());

    {
        wxGraphicsContext *gc = NULL;

        wxON_BLOCK_EXIT_OBJ1(gcFactory, DrawingTestGCFactory::CleanUp, gc);

        gc = gcFactory.BuildNewContext(
            wxSize(testCase.width, testCase.height),
            testCase.pointsPerInch, fileName);

        (this->*testCase.m_drawingF)(gc);

        gcFactory.SaveBuiltContext(gc);
    }

    if (GetBuildReference())
    {
         WX_ASSERT_MESSAGE(
             ("Cannot copy file \"%s\" to \"%s\".",
            fileName.GetFullPath(), refFileName.GetFullPath()),
            wxCopyFile (fileName.GetFullPath(),
                        refFileName.GetFullPath(), true));
    }
    else if (gcFactory.UseImageComparison())
    {
        WX_ASSERT_SAME_AS_IMAGE_FILE(fileName.GetFullPath(),
                                     refFileName.GetFullPath());
    }
    else
    {
        WX_ASSERT_SAME_AS_FILE(fileName.GetFullPath(),
                               refFileName.GetFullPath());
    }
}
Ejemplo n.º 3
0
void ScopeGuardTestCase::BlockExitObj()
{
    Counter count0(1),
            count1(2),
            count2(3);

    {
        wxON_BLOCK_EXIT_OBJ0(count0, Counter::Zero);
        wxON_BLOCK_EXIT_OBJ1(count1, Counter::Set, 17);
        wxON_BLOCK_EXIT_OBJ2(count2, Counter::Sum, 2, 3);

        CPPUNIT_ASSERT_EQUAL( 1, count0.GetCount() );
        CPPUNIT_ASSERT_EQUAL( 2, count1.GetCount() );
        CPPUNIT_ASSERT_EQUAL( 3, count2.GetCount() );
    }

    CPPUNIT_ASSERT_EQUAL( 0, count0.GetCount() );
    CPPUNIT_ASSERT_EQUAL( 17, count1.GetCount() );
    CPPUNIT_ASSERT_EQUAL( 5, count2.GetCount() );
}