Merge lp:~ted/ido/gtest into lp:ido/12.10

Proposed by Ted Gould
Status: Merged
Merged at revision: 109
Proposed branch: lp:~ted/ido/gtest
Merge into: lp:ido/12.10
Diff against target: 303 lines (+232/-1)
7 files modified
.bzrignore (+4/-0)
Makefile.am (+1/-1)
configure.ac (+8/-0)
m4/gtest.m4 (+63/-0)
src/idorange.h (+2/-0)
tests/Makefile.am (+52/-0)
tests/gtest-menuitems.cpp (+102/-0)
To merge this branch: bzr merge lp:~ted/ido/gtest
Reviewer Review Type Date Requested Status
jenkins (community) continuous-integration Approve
Charles Kerr (community) Needs Fixing
Review via email: mp+103564@code.launchpad.net

Description of the change

Adding the gtest framework and a few tests to make sure our menu items can be created and realized.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

ted, looks like this diff is missing the implementation of CHECK_XORG_GTEST.

Did you mean to bzr add another file into m4/ ?

review: Needs Fixing
Revision history for this message
Charles Kerr (charlesk) wrote :

d'oh, libxorg-gtest-dev

Revision history for this message
jenkins (martin-mrazik+qa) wrote :

PASSED: Continuous integration, rev:119
http://jenkins.qa.ubuntu.com/job/ido-ci/3/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ido-ci/./label=precise/3/console

review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

This was merged awhile back in revno: 109, finally closing out the merge requests and marking this as Merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-09-16 19:34:54 +0000
3+++ .bzrignore 2012-04-25 20:33:21 +0000
4@@ -28,3 +28,7 @@
5 src/libido3-0.1.la
6 src/stamp-idotypebuiltins.h
7 m4
8+m4/gtk-doc.m4
9+.deps
10+.libs
11+gtest-menuitems
12
13=== modified file 'Makefile.am'
14--- Makefile.am 2012-03-28 04:50:43 +0000
15+++ Makefile.am 2012-04-25 20:33:21 +0000
16@@ -10,7 +10,7 @@
17 Q = $(V:1=)
18 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
19
20-SUBDIRS = src example
21+SUBDIRS = src example tests
22
23 %-0.1.pc: %.pc
24 $(QUIET_GEN) cp -f $< $@
25
26=== modified file 'configure.ac'
27--- configure.ac 2012-04-12 15:18:01 +0000
28+++ configure.ac 2012-04-25 20:33:21 +0000
29@@ -57,6 +57,7 @@
30 # Checks for programs
31 AC_PROG_CC
32 AM_PROG_CC_C_O
33+AC_PROG_CXX
34
35 # Initialize libtool
36 LT_PREREQ([2.2])
37@@ -128,6 +129,12 @@
38 AC_SUBST(COVERAGE_CXXFLAGS)
39 AC_SUBST(COVERAGE_LDFLAGS)
40
41+dnl = Google Test Framework ===================================================
42+
43+m4_include([m4/gtest.m4])
44+CHECK_GTEST
45+CHECK_XORG_GTEST
46+
47 dnl = GTK Doc Check ===========================================================
48
49 GTK_DOC_CHECK([1.8])
50@@ -138,6 +145,7 @@
51 Makefile
52 src/Makefile
53 example/Makefile
54+ tests/Makefile
55 libido.pc
56 libido3.pc
57 ])
58
59=== added file 'm4/gtest.m4'
60--- m4/gtest.m4 1970-01-01 00:00:00 +0000
61+++ m4/gtest.m4 2012-04-25 20:33:21 +0000
62@@ -0,0 +1,63 @@
63+# Copyright (C) 2012 Canonical, Ltd.
64+#
65+# Permission is hereby granted, free of charge, to any person obtaining a copy
66+# of this software and associated documentation files (the "Software"), to deal
67+# in the Software without restriction, including without limitation the rights
68+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69+# copies of the Software, and to permit persons to whom the Software is
70+# furnished to do so, subject to the following conditions:
71+#
72+# The above copyright notice and this permission notice (including the next
73+# paragraph) shall be included in all copies or substantial portions of the
74+# Software.
75+#
76+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
82+# SOFTWARE.
83+
84+# Checks whether the gtest source is available on the system. Allows for
85+# adjusting the include and source path. Sets have_gtest=yes if the source is
86+# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
87+# source location respectively.
88+AC_DEFUN([CHECK_GTEST],
89+[
90+ AC_ARG_WITH([gtest-include-path],
91+ [AS_HELP_STRING([--with-gtest-include-path],
92+ [location of the Google test headers])],
93+ [GTEST_CPPFLAGS="-I$withval"])
94+
95+ AC_ARG_WITH([gtest-source-path],
96+ [AS_HELP_STRING([--with-gtest-source-path],
97+ [location of the Google test sources, defaults to /usr/src/gtest])],
98+ [GTEST_SOURCE="$withval"],
99+ [GTEST_SOURCE="/usr/src/gtest"])
100+
101+ GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
102+
103+ AC_LANG_PUSH([C++])
104+
105+ tmp_CPPFLAGS="$CPPFLAGS"
106+ CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
107+
108+ AC_CHECK_HEADER([gtest/gtest.h])
109+
110+ CPPFLAGS="$tmp_CPPFLAGS"
111+
112+ AC_LANG_POP
113+
114+ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
115+ [$GTEST_SOURCE/src/gtest_main.cc],
116+ [have_gtest_source=yes],
117+ [have_gtest_source=no])
118+
119+ AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \
120+ "x$have_gtest_source" = xyes],
121+ [have_gtest=yes]
122+ [AC_SUBST(GTEST_CPPFLAGS)]
123+ [AC_SUBST(GTEST_SOURCE)],
124+ [have_gtest=no])
125+]) # CHECK_GTEST
126
127=== modified file 'src/idorange.h'
128--- src/idorange.h 2011-10-05 17:41:37 +0000
129+++ src/idorange.h 2012-04-25 20:33:21 +0000
130@@ -28,6 +28,8 @@
131
132 #include <gtk/gtk.h>
133
134+G_BEGIN_DECLS
135+
136 #define IDO_TYPE_RANGE (ido_range_get_type ())
137 #define IDO_RANGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_RANGE, IdoRange))
138 #define IDO_RANGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), IDO_TYPE_RANGE, IdoRangeClass))
139
140=== added directory 'tests'
141=== added file 'tests/Makefile.am'
142--- tests/Makefile.am 1970-01-01 00:00:00 +0000
143+++ tests/Makefile.am 2012-04-25 20:33:21 +0000
144@@ -0,0 +1,52 @@
145+if USE_GTK3
146+VER=3
147+IDOLIB = $(top_builddir)/src/libido3-0.1.la
148+else
149+VER=
150+IDOLIB = $(top_builddir)/src/libido-0.1.la
151+endif
152+
153+check_LIBRARIES = libgtest.a
154+check_PROGRAMS =
155+TESTS =
156+
157+AM_CPPFLAGS = \
158+ $(GTEST_CPPFLAGS) \
159+ -I${top_srcdir}/src
160+
161+#############################
162+# Google Test base library
163+#############################
164+
165+nodist_libgtest_a_SOURCES = \
166+ $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \
167+ $(GTEST_SOURCE)/src/gtest-all.cc \
168+ $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp
169+libgtest_a_CPPFLAGS = \
170+ $(XORG_GTEST_CPPFLAGS) \
171+ $(AM_CPPFLAGS) \
172+ $(GTEST_CPPFLAGS) -w
173+libgtest_a_CXXFLAGS = \
174+ $(AM_CXXFLAGS)
175+
176+#############################
177+# Menuitem tests
178+#############################
179+
180+TESTS += gtest-menuitems
181+check_PROGRAMS += gtest-menuitems
182+
183+gtest_menuitems_SOURCES = \
184+ gtest-menuitems.cpp
185+gtest_menuitems_CPPFLAGS = \
186+ $(GCC_CFLAGS) \
187+ $(GTK_CFLAGS) \
188+ $(MAINTAINER_CFLAGS) \
189+ $(AM_CPPFLAGS)
190+gtest_menuitems_LDFLAGS = \
191+ -pthread
192+gtest_menuitems_LDADD = \
193+ $(GTK_LIBS) \
194+ $(IDOLIB) \
195+ libgtest.a
196+
197
198=== added file 'tests/gtest-menuitems.cpp'
199--- tests/gtest-menuitems.cpp 1970-01-01 00:00:00 +0000
200+++ tests/gtest-menuitems.cpp 2012-04-25 20:33:21 +0000
201@@ -0,0 +1,102 @@
202+
203+#include <gtk/gtk.h>
204+#include <gtest/gtest.h>
205+#include "idocalendarmenuitem.h"
206+#include "idoentrymenuitem.h"
207+#include "idoscalemenuitem.h"
208+
209+class TestMenuitems : public ::testing::Test
210+{
211+public:
212+ TestMenuitems()
213+ {
214+ gint argc = 0;
215+ gchar * argv[] = {NULL};
216+ gtk_init(&argc, (gchar ***)&argv);
217+ return;
218+ }
219+};
220+
221+TEST_F(TestMenuitems, BuildCalendar) {
222+ GtkWidget * cal = ido_calendar_menu_item_new();
223+
224+ EXPECT_TRUE(cal != NULL);
225+ EXPECT_TRUE(IDO_IS_CALENDAR_MENU_ITEM(cal));
226+ EXPECT_TRUE(GTK_IS_MENU_ITEM(cal));
227+
228+ GtkWidget * menu = gtk_menu_new();
229+ gtk_widget_show(menu);
230+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), cal);
231+
232+ gtk_widget_show(cal);
233+ gtk_widget_realize(cal);
234+
235+ EXPECT_TRUE(gtk_widget_get_realized(cal));
236+
237+ g_object_ref_sink(menu);
238+ g_object_unref(menu);
239+ return;
240+}
241+
242+TEST_F(TestMenuitems, BuildEntry) {
243+ GtkWidget * entry = ido_entry_menu_item_new();
244+
245+ EXPECT_TRUE(entry != NULL);
246+ EXPECT_TRUE(IDO_IS_ENTRY_MENU_ITEM(entry));
247+ EXPECT_TRUE(GTK_IS_MENU_ITEM(entry));
248+
249+ GtkWidget * menu = gtk_menu_new();
250+ gtk_widget_show(menu);
251+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
252+
253+ gtk_widget_show(entry);
254+ gtk_widget_realize(entry);
255+
256+ EXPECT_TRUE(gtk_widget_get_realized(entry));
257+
258+ g_object_ref_sink(menu);
259+ g_object_unref(menu);
260+ return;
261+}
262+
263+TEST_F(TestMenuitems, BuildScaleDefault) {
264+ GtkWidget * scale = ido_scale_menu_item_new("Label", IDO_RANGE_STYLE_DEFAULT, gtk_adjustment_new(0.5, 0.0, 1.0, 0.01, 0.1, 0.1));
265+
266+ EXPECT_TRUE(scale != NULL);
267+ EXPECT_TRUE(IDO_IS_SCALE_MENU_ITEM(scale));
268+ EXPECT_TRUE(GTK_IS_MENU_ITEM(scale));
269+
270+ GtkWidget * menu = gtk_menu_new();
271+ gtk_widget_show(menu);
272+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), scale);
273+
274+ gtk_widget_show(scale);
275+ gtk_widget_realize(scale);
276+
277+ EXPECT_TRUE(gtk_widget_get_realized(scale));
278+
279+ g_object_ref_sink(menu);
280+ g_object_unref(menu);
281+ return;
282+}
283+
284+TEST_F(TestMenuitems, BuildScaleSmall) {
285+ GtkWidget * scale = ido_scale_menu_item_new("Label", IDO_RANGE_STYLE_SMALL, gtk_adjustment_new(0.5, 0.0, 1.0, 0.01, 0.1, 0.1));
286+
287+ EXPECT_TRUE(scale != NULL);
288+ EXPECT_TRUE(IDO_IS_SCALE_MENU_ITEM(scale));
289+ EXPECT_TRUE(GTK_IS_MENU_ITEM(scale));
290+
291+ GtkWidget * menu = gtk_menu_new();
292+ gtk_widget_show(menu);
293+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), scale);
294+
295+ gtk_widget_show(scale);
296+ gtk_widget_realize(scale);
297+
298+ EXPECT_TRUE(gtk_widget_get_realized(scale));
299+
300+ g_object_ref_sink(menu);
301+ g_object_unref(menu);
302+ return;
303+}

Subscribers

People subscribed via source and target branches