Scroom  0.14
transformpresentation_test.cc File Reference
#include <gmock/gmock-more-actions.h>
#include <gtest/gtest.h>
#include <scroom/bitmap-helpers.hh>
#include <scroom/dont-delete.hh>
#include <scroom/gmock/presentationinterface.hh>
#include <scroom/rectangle.hh>
#include <scroom/transformpresentation.hh>
Include dependency graph for transformpresentation_test.cc:

Functions

bool points_are_close (Scroom::Utils::Point< double > const &a, Scroom::Utils::Point< double > const &b)
 
bool rects_are_close (Scroom::Utils::Rectangle< double > const &a, Scroom::Utils::Rectangle< double > const &b)
 
bool operator== (ViewInterface::WeakPtr const &a, ViewInterface::WeakPtr const &b)
 
 TEST (TransformPresentation_Tests, TransformationData_supports_aspect_ratio)
 

Function Documentation

◆ operator==()

bool operator== ( ViewInterface::WeakPtr const &  a,
ViewInterface::WeakPtr const &  b 
)
39 { return a.lock() == b.lock(); }
Here is the call graph for this function:

◆ points_are_close()

bool points_are_close ( Scroom::Utils::Point< double > const &  a,
Scroom::Utils::Point< double > const &  b 
)
30 {
31  return (a - b).magnitude() < 1e-6;
32 }

Referenced by rects_are_close(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rects_are_close()

bool rects_are_close ( Scroom::Utils::Rectangle< double > const &  a,
Scroom::Utils::Rectangle< double > const &  b 
)
35 {
36  return points_are_close(a.getTopLeft(), b.getTopLeft()) && points_are_close(a.getBottomRight(), b.getBottomRight());
37 }

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST()

TEST ( TransformPresentation_Tests  ,
TransformationData_supports_aspect_ratio   
)
42 {
44  td->setAspectRatio(2, 3);
45  EXPECT_PRED2(points_are_close, Scroom::Utils::Point<double>(2, 3), td->getAspectRatio());
46 
48 
50 
51  ViewInterface::Ptr const vi(reinterpret_cast<ViewInterface*>(1), DontDelete<ViewInterface>());
52  EXPECT_CALL(*cpm, getRect()).WillRepeatedly(Return(make_rect(1.0, 2.0, 3.0, 4.0)));
53 
55  Sequence const seq;
56  EXPECT_CALL(*cpm, open(_)).InSequence(seq).WillOnce(SaveArg<0>(&viw));
57  const Scroom::Utils::Rectangle<double> to_be_drawn = make_rect(1.0, 4.5, 4.0, 9.0);
58  const int zoom_to_use = 3;
59  Scroom::Utils::Rectangle<double> requested_to_be_drawn;
60  int used_zoom;
61  EXPECT_CALL(*cpm, redraw(Eq(ByRef(viw)), _, _, _)).WillOnce(DoAll(SaveArg<2>(&requested_to_be_drawn), SaveArg<3>(&used_zoom)));
62  EXPECT_CALL(*cpm, close(Eq(ByRef(viw))));
63 
64  Scroom::Utils::Rectangle<double> const r = tp->getRect();
65  EXPECT_PRED2(rects_are_close, make_rect(2.0, 6.0, 6.0, 12.0), r);
66 
67  tp->open(vi);
68 
69  BitmapSurface::Ptr const s = BitmapSurface::create(10, 10, CAIRO_FORMAT_ARGB32);
70  cairo_surface_t* surface = s->get();
71  cairo_t* cr = cairo_create(surface);
72 
73  tp->redraw(vi, cr, to_be_drawn, zoom_to_use);
74 
75  EXPECT_PRED2(rects_are_close, make_rect(0.5, 1.5, 2.0, 3.0), requested_to_be_drawn);
76  EXPECT_EQ(zoom_to_use, used_zoom);
77  cairo_destroy(cr);
78 
79  tp->close(vi);
80 }
Here is the call graph for this function:
TransformationData::Ptr
boost::shared_ptr< TransformationData > Ptr
Definition: transformpresentation.hh:26
Scroom::Utils::Rectangle::getTopLeft
xy_type getTopLeft() const
Definition: rectangle.hh:133
Scroom::MemoryBlocks::RawPageData::Ptr
boost::shared_ptr< uint8_t > Ptr
Definition: blockallocator.hh:23
ViewInterface::Ptr
boost::shared_ptr< ViewInterface > Ptr
Definition: viewinterface.hh:193
Scroom::Utils::make_rect
Rectangle< T > make_rect(T x, T y, T width, T height)
Definition: rectangle.hh:284
DontDelete
Definition: dont-delete.hh:25
TransformationData::create
static Ptr create()
Definition: transformpresentation.cc:28
ColormappablePresentationMock::create
static Ptr create()
Definition: presentationinterface.hh:39
TransformPresentation::Ptr
boost::shared_ptr< TransformPresentation > Ptr
Definition: transformpresentation.hh:83
Scroom::Utils::Rectangle::getBottomRight
xy_type getBottomRight() const
Definition: rectangle.hh:139
ViewInterface::WeakPtr
boost::weak_ptr< ViewInterface > WeakPtr
Definition: viewinterface.hh:194
ColormappablePresentationMock::Ptr
boost::shared_ptr< ColormappablePresentationMock > Ptr
Definition: presentationinterface.hh:37
TransformPresentation::create
static Ptr create(PresentationInterface::Ptr const &presentation, TransformationData::Ptr const &transformationData)
Definition: transformpresentation.cc:51
points_are_close
bool points_are_close(Scroom::Utils::Point< double > const &a, Scroom::Utils::Point< double > const &b)
Definition: transformpresentation_test.cc:29
b
static void b(const B::Ptr &)
Definition: gtkhelper-tests.cc:32
Scroom::Tiff::open
boost::optional< std::tuple< Scroom::TiledBitmap::BitmapMetaData, TIFFPtr > > open(const std::string &fileName)
Definition: tiffsource.cc:119
Scroom::Utils::Rectangle< double >
ViewInterface
Definition: viewinterface.hh:190
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175
rects_are_close
bool rects_are_close(Scroom::Utils::Rectangle< double > const &a, Scroom::Utils::Rectangle< double > const &b)
Definition: transformpresentation_test.cc:34
Scroom::Utils::Point< double >