Commit 0162904c authored by Dave DeMarle's avatar Dave DeMarle Committed by Code Review
Browse files

Merge topic 'TestErrorObserver' into master

28332fd4 ENH: Coverage is 100%
e256de28 ENH: Add a convenient testing class for observing errors
parents 79d81052 28332fd4
......@@ -13,6 +13,7 @@
=========================================================================*/
#include "vtkTestErrorObserver.h"
#include "vtkLookupTable.h"
#include "vtkColorSeries.h"
#include "vtkColor.h"
......@@ -220,6 +221,7 @@ int TestColorSeries( int argc, char* argv[] )
vtkGenericWarningMacro( "Failure: DeepCopy did not preserve current scheme" );
valResult = vtkTesting::FAILED;
}
other->DeepCopy(NULL);
// Test SetColor
other->SetColorScheme( pid );
......@@ -231,8 +233,27 @@ int TestColorSeries( int argc, char* argv[] )
valResult = vtkTesting::FAILED;
}
// Build a lookup table
vtkLookupTable* lut = palettes->BuildLookupTable(NULL);
lut->Print(std::cout);
lut->Delete();
// Test scheme out of range warning
VTK_CREATE(vtkTest::ErrorObserver, warningObserver);
palettes->AddObserver(vtkCommand::WarningEvent, warningObserver);
palettes->SetColorScheme(1000);
if (warningObserver->GetWarning())
{
std::cout << "Caught expected warning: "
<< warningObserver->GetWarningMessage() << std::endl;
}
else
{
vtkGenericWarningMacro( "Failure: SetColorScheme(1000) did not produce expected warning" );
valResult = vtkTesting::FAILED;
}
vtkIndent indent;
palettes->PrintSelf(cout, indent);
palettes->PrintSelf(std::cout, indent);
t->Delete();
return (
......
......@@ -13,7 +13,6 @@
=========================================================================*/
#include "vtkNew.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
......@@ -21,30 +20,15 @@
#include "vtkPolyDataMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkTestUtilities.h"
#include "vtkTestErrorObserver.h"
#include "vtkGlyph3D.h"
#include "vtkSmartPointer.h"
#include "vtkDoubleArray.h"
#include <vtkPointData.h>
#include <vtkConeSource.h>
#include <vtkCamera.h>
#include <vtkCommand.h>
#include "vtkPointData.h"
#include "vtkConeSource.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
class ErrorObserver
{
bool Error;
public:
ErrorObserver():Error(false)
{
}
bool GetError() const
{
return this->Error;
}
void onErrorEvent()
{
this->Error = true;
}
};
static bool TestGlyph3D_WithBadArray()
{
vtkSmartPointer<vtkDoubleArray> vectors =
......@@ -74,11 +58,11 @@ static bool TestGlyph3D_WithBadArray()
glyph3D->SetInputData(polydata);
glyph3D->SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"Normals");
glyph3D->SetVectorModeToUseVector();
ErrorObserver* errorObserver= new ErrorObserver();
glyph3D->AddObserver(vtkCommand::ErrorEvent,errorObserver,&ErrorObserver::onErrorEvent);
vtkSmartPointer<vtkTest::ErrorObserver> errorObserver =
vtkSmartPointer<vtkTest::ErrorObserver>::New();
glyph3D->AddObserver(vtkCommand::ErrorEvent,errorObserver);
glyph3D->Update();
bool res = errorObserver->GetError();
delete errorObserver;
return res;
}
......@@ -130,18 +114,22 @@ int TestGlyph3D(int argc, char* argv[])
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(glyph3D->GetOutputPort());
vtkNew<vtkActor> actor;
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper.GetPointer());
vtkNew<vtkRenderer> ren;
vtkSmartPointer<vtkRenderer> ren =
vtkSmartPointer<vtkRenderer>::New();
ren->SetBackground(0,0,0);
ren->AddActor(actor.GetPointer());
ren->ResetCamera();
ren->GetActiveCamera()->Zoom(1.5);
vtkNew<vtkRenderWindow> renWin;
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
vtkNew<vtkRenderWindowInteractor> iren;
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren.GetPointer());
......
......@@ -2,13 +2,13 @@
#include <vtkSampleFunction.h>
#include <vtkSphere.h>
#include "TestImagingHybrid.h"
#include "vtkTestErrorObserver.h"
int TestSampleFunction(int, char *[])
{
// First test for errors and warniongs
vtkSmartPointer<ErrorObserver> errorObserver =
vtkSmartPointer<ErrorObserver>::New();
vtkSmartPointer<vtkTest::ErrorObserver> errorObserver =
vtkSmartPointer<vtkTest::ErrorObserver>::New();
vtkSmartPointer<vtkSampleFunction> sf1 =
vtkSmartPointer<vtkSampleFunction>::New();
......
#ifndef __TestImagingHybrid_h
#define __TestImagingHybrid_h
/*=========================================================================
Program: Visualization Toolkit
Module: TestErrorObserver.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef __vtkTestErrorObserver_h
#define __vtkTestErrorObserver_h
#include <vtkCommand.h>
#include <string>
class ErrorObserver : public vtkCommand
namespace vtkTest
{
class ErrorObserver : public ::vtkCommand
{
public:
ErrorObserver():
......@@ -59,4 +77,5 @@ private:
std::string ErrorMessage;
std::string WarningMessage;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment