Back to index

nux  3.0.0
Helpers.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright 2011 Inalogic® Inc.
00004  *
00005  * This program is free software: you can redistribute it and/or modify it
00006  * under the terms of the GNU Lesser General Public License, as
00007  * published by the  Free Software Foundation; either version 2.1 or 3.0
00008  * of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranties of
00012  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00013  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of both the GNU Lesser General Public
00017  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00018  *
00019  * Authored by: Tim Penhey <tim.penhey@canonical.com>
00020  *
00021  */
00022 #ifndef NUX_TESTS_FILE_HELPERS_H
00023 #define NUX_TESTS_FILE_HELPERS_H
00024 
00025 #include <string>
00026 #include <glib.h>
00027 #include <sigc++/sigc++.h>
00028 
00029 
00030 namespace nux
00031 {
00032 namespace testing
00033 {
00034 
00035 std::string ReadFile(std::string const& filename);
00036 void PumpGObjectMainLoop();
00037 
00038 class TestCallback
00039 {
00040 public:
00041   TestCallback() : happened(false) {}
00042 
00043   sigc::slot<void> sigc_callback() {
00044     return sigc::mem_fun(this, &TestCallback::callback);
00045   }
00046 
00047   static gboolean glib_callback(gpointer data) {
00048     TestCallback* test = reinterpret_cast<TestCallback*>(data);
00049     test->callback();
00050     return FALSE;
00051   }
00052   void callback() {
00053     happened = true;
00054   }
00055 
00056   bool happened;
00057 };
00058 
00059 
00060 }
00061 }
00062 
00063 #endif