Back to index

nux  3.0.0
Typedefs | Functions | Variables
gtest-nux-cairo-wrapper.cpp File Reference
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "Nux/CairoWrapper.h"
#include <string>
#include <fstream>
#include <iostream>

Go to the source code of this file.

Typedefs

typedef void(* TestFunc )(void)

Functions

void callback_one (nux::Geometry const &geom, cairo_t *cr)
void callback_two (nux::Geometry const &geom, cairo_t *cr)
void terminate (void *data)
void init (nux::NThread *thread, void *data)
void run_test (TestFunc func)
void test_construction ()
void test_invalidate ()
void test_get_cairo_surface ()
void test_get_cairo_context ()
void test_dump_to_file ()
void test_get_texture ()
void test_get_bitmap ()

Variables

nux::TimerFunctorg_timer = NULL
nux::TimerHandle g_handler = NULL

Typedef Documentation

typedef void(* TestFunc)(void)

Definition at line 29 of file gtest-nux-cairo-wrapper.cpp.


Function Documentation

void callback_one ( nux::Geometry const &  geom,
cairo_t *  cr 
)

Definition at line 35 of file gtest-nux-cairo-wrapper.cpp.

{
  if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
    return;

  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint (cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
  cairo_scale (cr, 1.0, 1.0);
  cairo_set_source_rgba (cr, 1.0, 0.5, 0.25, 1.0);
  cairo_rectangle (cr,
                   5.0,
                   5.0,
                   (double) geom.width - 10.0,
                   (double) geom.height - 10.0);
  cairo_fill (cr);
}

Here is the caller graph for this function:

void callback_two ( nux::Geometry const &  geom,
cairo_t *  cr 
)

Definition at line 54 of file gtest-nux-cairo-wrapper.cpp.

{
  if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
    return;

  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint (cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  cairo_scale (cr, 1.0, 1.0);
  cairo_set_source_rgba (cr, 0.25, 0.5, 1.0, 1.0);
  cairo_rectangle (cr,
                   2.0,
                   2.0,
                   (double) geom.width - 4.0,
                   (double) geom.height - 4.0);
  cairo_fill (cr);
}
void init ( nux::NThread thread,
void *  data 
)

Definition at line 80 of file gtest-nux-cairo-wrapper.cpp.

{
  TestFunc func = (TestFunc) data;

  (func) ();

  g_timer = new nux::TimerFunctor ();
  g_timer->time_expires.connect (sigc::ptr_fun (&terminate));
  g_handler = nux::GetTimer().AddTimerHandler (100,
                                               g_timer,
                                               nux::GetWindowThread ());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void run_test ( TestFunc  func)

Definition at line 94 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::WindowThread* wt = NULL;

  wt = nux::CreateGUIThread (TEXT ("Canvas Test"), 400, 400, 0, &init, (void*) func);
  wt->Run (NULL);
  delete wt;
  delete g_timer;
  g_timer = NULL;
}

Here is the call graph for this function:

void terminate ( void *  data)

Definition at line 73 of file gtest-nux-cairo-wrapper.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 106 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom_one = {0, 0, 100, 100};
  nux::Geometry geom_two = {0, 0, 200, 200};
  nux::CairoWrapper wrapper (geom_one, sigc::ptr_fun (callback_one));

  EXPECT_FALSE (wrapper.Invalidate (geom_one));
  EXPECT_TRUE (wrapper.Invalidate (geom_two));
}

Here is the call graph for this function:

Definition at line 147 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom = {0, 0, 100, 100};
  nux::CairoWrapper wrapper (geom, sigc::ptr_fun (callback_one));

  EXPECT_TRUE (wrapper.DumpToFile ("/tmp/dump.png"));
}

Here is the call graph for this function:

void test_get_bitmap ( )

Definition at line 165 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom = {0, 0, 100, 100};
  nux::CairoWrapper wrapper (geom, sigc::ptr_fun (callback_one));

  EXPECT_TRUE (wrapper.GetBitmap ());
}

Here is the call graph for this function:

Definition at line 138 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom = {0, 0, 100, 100};
  nux::CairoWrapper wrapper (geom, sigc::ptr_fun (callback_one));

  EXPECT_TRUE (wrapper.GetCairoContext ());
}

Here is the call graph for this function:

Definition at line 128 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom = {0, 0, 100, 100};
  nux::CairoWrapper wrapper (geom, sigc::ptr_fun (callback_one));

  cairo_surface_t* surf = wrapper.GetCairoSurface ();
  EXPECT_FALSE (surf == NULL);
}

Here is the call graph for this function:

void test_get_texture ( )

Definition at line 156 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom = {0, 0, 100, 100};
  nux::CairoWrapper wrapper (geom, sigc::ptr_fun (callback_one));

  EXPECT_TRUE (wrapper.GetTexture ());
}

Here is the call graph for this function:

void test_invalidate ( )

Definition at line 117 of file gtest-nux-cairo-wrapper.cpp.

{
  nux::Geometry geom_one = {0, 0, 100, 100};
  nux::Geometry geom_two = {0, 0, 150, 75};
  nux::CairoWrapper wrapper (geom_one, sigc::ptr_fun (callback_one));

  EXPECT_FALSE (wrapper.Invalidate (geom_one));
  EXPECT_TRUE (wrapper.Invalidate (geom_two));
}

Here is the call graph for this function:


Variable Documentation

Definition at line 32 of file gtest-nux-cairo-wrapper.cpp.

Definition at line 31 of file gtest-nux-cairo-wrapper.cpp.