Nux

Merge lp:~unity-team/nux/nux.test-files-renaming into lp:nux/2.0

Proposed by Jay Taoko
Status: Merged
Approved by: Jay Taoko
Approved revision: 585
Merged at revision: 585
Proposed branch: lp:~unity-team/nux/nux.test-files-renaming
Merge into: lp:nux/2.0
Diff against target: 413 lines (+176/-77)
6 files modified
Nux/View.cpp (+0/-3)
tests/Makefile.am (+49/-49)
tests/gtest-nux-area.cpp (+74/-0)
tests/gtest-nux-view.cpp (+37/-0)
tests/gtest-nuxcore-logger.cpp (+1/-1)
tests/gtest-nuxcore-object.cpp (+15/-24)
To merge this branch: bzr merge lp:~unity-team/nux/nux.test-files-renaming
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Review via email: mp+94677@code.launchpad.net

Description of the change

* Renaming of tests files
* In nux::View class, do not set the minimum size of the area.
* Added tests for nux::View and nux::Area.

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/View.cpp'
2--- Nux/View.cpp 2012-02-22 16:41:47 +0000
3+++ Nux/View.cpp 2012-02-26 02:38:17 +0000
4@@ -36,9 +36,6 @@
5 view_layout_ = NULL;
6 draw_cmd_queued_ = false;
7 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
8-
9- // Set widget default size;
10- SetMinimumSize(DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
11 }
12
13 View::~View()
14
15=== modified file 'tests/Makefile.am'
16--- tests/Makefile.am 2012-02-23 06:49:05 +0000
17+++ tests/Makefile.am 2012-02-26 02:38:17 +0000
18@@ -1,8 +1,7 @@
19 if BUILD_TESTS
20 check_PROGRAMS = \
21- test-nux \
22 gtest-nux \
23- gtest-nux-core \
24+ gtest-nuxcore \
25 test-graphics-display \
26 test-empty-window \
27 xtest-button \
28@@ -18,45 +17,44 @@
29 xtest-focus-on-mouse-enter
30
31 # Please keep alphabetical
32-test_nux_SOURCES = \
33- test-canvas.cpp \
34- test-nux.cpp \
35- test-system.cpp
36-
37-test_nux_CPPFLAGS = \
38- -I$(srcdir) \
39- -I$(top_srcdir) \
40- -DPREFIX=\""$(prefix)"\" \
41- -DLIBDIR=\""$(libdir)"\" \
42- -DDATADIR=\""$(datadir)"\" \
43- -DG_LOG_DOMAIN=\"NuxTests\" \
44- -DTESTDIR=\""$(top_srcdir)/tests"\" \
45- $(GCC_FLAGS) \
46- $(NUX_CORE_CFLAGS) \
47- $(NUX_EXAMPLES_CFLAGS) \
48- $(NUX_CFLAGS) \
49- $(MAINTAINER_CFLAGS)
50-
51-test_nux_LDADD = \
52- $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
53- $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \
54- $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \
55- $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \
56- $(NUX_LIBS)
57-
58-gtest_nux_core_SOURCES = \
59+# test_nux_SOURCES = \
60+# test-canvas.cpp \
61+# test-nux.cpp \
62+# test-system.cpp
63+
64+#test_nux_CPPFLAGS = \
65+# -I$(srcdir) \
66+# -I$(top_srcdir) \
67+# -DPREFIX=\""$(prefix)"\" \
68+# -DLIBDIR=\""$(libdir)"\" \
69+# -DDATADIR=\""$(datadir)"\" \
70+# -DG_LOG_DOMAIN=\"NuxTests\" \
71+# -DTESTDIR=\""$(top_srcdir)/tests"\" \
72+# $(GCC_FLAGS) \
73+# $(NUX_CORE_CFLAGS) \
74+# $(NUX_EXAMPLES_CFLAGS) \
75+# $(NUX_CFLAGS) \
76+# $(MAINTAINER_CFLAGS)
77+
78+#test_nux_LDADD = \
79+# $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
80+# $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \
81+# $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \
82+# $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \
83+# $(NUX_LIBS)
84+
85+gtest_nuxcore_SOURCES = \
86 Helpers.h \
87 Helpers.cpp \
88+ gtest-nuxcore-async-file-writer.cpp \
89 gtest-nuxcore-color.cpp \
90- test_object.cpp \
91- test_main.cpp \
92- test_async_file_writer.cpp \
93- test_logger.cpp \
94- test_cairo_wrapper.cpp \
95- test_properties.cpp \
96- test_rolling_file_appender.cpp
97+ gtest-nuxcore-logger.cpp \
98+ gtest-nuxcore-main.cpp \
99+ gtest-nuxcore-object.cpp \
100+ gtest-nuxcore-properties.cpp \
101+ gtest-nuxcore-rolling-file-appender.cpp
102
103-gtest_nux_core_CPPFLAGS = \
104+gtest_nuxcore_CPPFLAGS = \
105 -I$(srcdir) \
106 -I$(top_srcdir) \
107 -DPREFIX=\""$(prefix)"\" \
108@@ -70,24 +68,26 @@
109 $(NUX_CFLAGS) \
110 $(MAINTAINER_CFLAGS)
111
112-gtest_nux_core_LDADD = \
113+gtest_nuxcore_LDADD = \
114 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
115 $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \
116 $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \
117 $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \
118 $(NUX_LIBS)
119
120-gtest_nux_core_LDFLAGS = \
121+gtest_nuxcore_LDFLAGS = \
122 -lpthread -lgtest -lgmock \
123 -lboost_filesystem -lboost_system
124
125 gtest_nux_SOURCES = \
126- test-nux-main.cpp \
127- test-nux-metrics.cpp \
128- test-nux-statictext.cpp \
129+ gtest-nux-area.cpp \
130+ gtest-nux-cairo-wrapper.cpp \
131+ gtest-nux-emmetrics.cpp \
132+ gtest-nux-main.cpp \
133+ gtest-nux-statictext.cpp \
134+ gtest-nux-view.cpp \
135 gtest-nux-windowcompositor.cpp \
136- test-nux-windowthread.cpp
137-
138+ gtest-nux-windowthread.cpp
139
140 gtest_nux_CPPFLAGS = \
141 -I$(srcdir) \
142@@ -243,14 +243,14 @@
143 check-local: test gtest test-apps
144
145 test:
146- @gtester --verbose -k -o=test-nux-results.xml ./test-nux
147+ @gtester --verbose -k -o=gtest-nux-results.xml ./gtest-nux
148
149-gtest: gtest-nux-core gtest-nux
150- ./gtest-nux-core
151+gtest: gtest-nuxcore gtest-nux
152+ ./gtest-nuxcore
153 ./gtest-nux
154
155-check-headless: gtest-nux-core
156- @gtester --verbose -k -o=test-nux-results.xml ./gtest-nux-core
157+check-headless: gtest-nuxcore
158+ @gtester --verbose -k -o=test-nux-results.xml ./gtest-nuxcore
159
160 test-apps: test-graphics-display test-empty-window xtest-text-entry xtest-button xtest-mouse-events xtest-mouse-buttons xtest-hgrid-key-navigation xtest-hlayout-key-navigation xtest-vlayout-key-navigation xtest-scrollbar xtest-focus-on-mouse-down xtest-focus-on-mouse-enter xtest-keynav-directions
161 ./test-graphics-display
162
163=== added file 'tests/gtest-nux-area.cpp'
164--- tests/gtest-nux-area.cpp 1970-01-01 00:00:00 +0000
165+++ tests/gtest-nux-area.cpp 2012-02-26 02:38:17 +0000
166@@ -0,0 +1,74 @@
167+#include <string>
168+#include <fstream>
169+
170+#include <iostream>
171+#include <gmock/gmock.h>
172+#include <boost/filesystem.hpp>
173+#include <glib.h>
174+
175+#include "Nux/Nux.h"
176+#include "Nux/StaticText.h"
177+#include "Nux/ProgramFramework/TestView.h"
178+
179+
180+using namespace testing;
181+
182+namespace {
183+
184+TEST(TestArea, TestAreaSize)
185+{
186+ nux::NuxInitialize(0);
187+ nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Area Test", 300, 200,
188+ nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
189+
190+ nux::TestView* test_view = new nux::TestView("");
191+
192+ EXPECT_EQ(test_view->GetMinimumWidth(), nux::AREA_MIN_WIDTH);
193+ EXPECT_EQ(test_view->GetMaximumWidth(), nux::AREA_MAX_WIDTH);
194+ EXPECT_EQ(test_view->GetMinimumHeight(), nux::AREA_MIN_HEIGHT);
195+ EXPECT_EQ(test_view->GetMaximumHeight(), nux::AREA_MAX_HEIGHT);
196+
197+ test_view->SetMinimumWidth(100);
198+ EXPECT_EQ(test_view->GetMinimumWidth(), 100);
199+
200+ test_view->SetMaximumWidth(1111);
201+ EXPECT_EQ(test_view->GetMaximumWidth(), 1111);
202+
203+ test_view->SetMinimumHeight(123);
204+ EXPECT_EQ(test_view->GetMinimumHeight(), 123);
205+
206+ test_view->SetMaximumHeight(1234);
207+ EXPECT_EQ(test_view->GetMaximumHeight(), 1234);
208+
209+ test_view->SetMaximumSize(4321, 1234);
210+ test_view->SetMinimumSize(123, 432);
211+
212+ EXPECT_EQ(test_view->GetMinimumWidth(), 123);
213+ EXPECT_EQ(test_view->GetMaximumWidth(), 4321);
214+ EXPECT_EQ(test_view->GetMinimumHeight(), 432);
215+ EXPECT_EQ(test_view->GetMaximumHeight(), 1234);
216+
217+ test_view->UnReference();
218+ delete wnd_thread;
219+}
220+
221+TEST(TestArea, TestAreaGeometry)
222+{
223+ nux::NuxInitialize(0);
224+ nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Area Test", 300, 200,
225+ nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
226+
227+ nux::TestView* test_view = new nux::TestView("");
228+
229+ static_cast<nux::Area*>(test_view)->SetGeometry(0, 0, 100, 100);
230+
231+ EXPECT_EQ(test_view->GetBaseX(), 0);
232+ EXPECT_EQ(test_view->GetBaseX(), 0);
233+ EXPECT_EQ(test_view->GetBaseWidth(), 100);
234+ EXPECT_EQ(test_view->GetBaseHeight(), 100);
235+
236+
237+ test_view->UnReference();
238+ delete wnd_thread;
239+}
240+}
241
242=== renamed file 'tests/test_cairo_wrapper.cpp' => 'tests/gtest-nux-cairo-wrapper.cpp'
243=== renamed file 'tests/test-nux-metrics.cpp' => 'tests/gtest-nux-emmetrics.cpp'
244=== renamed file 'tests/test-nux-main.cpp' => 'tests/gtest-nux-main.cpp'
245=== renamed file 'tests/test-nux-statictext.cpp' => 'tests/gtest-nux-statictext.cpp'
246=== added file 'tests/gtest-nux-view.cpp'
247--- tests/gtest-nux-view.cpp 1970-01-01 00:00:00 +0000
248+++ tests/gtest-nux-view.cpp 2012-02-26 02:38:17 +0000
249@@ -0,0 +1,37 @@
250+#include <string>
251+#include <fstream>
252+
253+#include <iostream>
254+#include <gmock/gmock.h>
255+#include <boost/filesystem.hpp>
256+#include <glib.h>
257+
258+#include "Nux/Nux.h"
259+#include "Nux/StaticText.h"
260+#include "Nux/ProgramFramework/TestView.h"
261+
262+
263+using namespace testing;
264+
265+namespace {
266+
267+TEST(TestView, TestViewEnable)
268+{
269+ nux::NuxInitialize(0);
270+ nux::WindowThread *wnd_thread = nux::CreateNuxWindow("View Test", 300, 200,
271+ nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
272+
273+ nux::TestView* test_view = new nux::TestView("");
274+
275+ test_view->EnableView();
276+ EXPECT_TRUE(test_view->IsViewEnabled());
277+
278+ test_view->DisableView();
279+ EXPECT_FALSE(test_view->IsViewEnabled());
280+
281+
282+ test_view->UnReference();
283+ delete wnd_thread;
284+}
285+
286+}
287
288=== renamed file 'tests/test-nux-windowthread.cpp' => 'tests/gtest-nux-windowthread.cpp'
289=== renamed file 'tests/test_async_file_writer.cpp' => 'tests/gtest-nuxcore-async-file-writer.cpp'
290=== renamed file 'tests/test_logger.cpp' => 'tests/gtest-nuxcore-logger.cpp'
291--- tests/test_logger.cpp 2011-08-03 04:26:34 +0000
292+++ tests/gtest-nuxcore-logger.cpp 2012-02-26 02:38:17 +0000
293@@ -238,7 +238,7 @@
294 std::string result = out.str();
295
296 EXPECT_THAT(result, StartsWith("DEBUG"));
297- EXPECT_THAT(result, HasSubstr(" test.module test_logger.cpp"));
298+ EXPECT_THAT(result, HasSubstr(" test.module gtest-nuxcore-logger.cpp"));
299 EXPECT_THAT(result, EndsWith("1 Is output now.\n"));
300 // Also only one line.
301 EXPECT_THAT(counter, Eq(1));
302
303=== renamed file 'tests/test_main.cpp' => 'tests/gtest-nuxcore-main.cpp'
304=== renamed file 'tests/test_object.cpp' => 'tests/gtest-nuxcore-object.cpp'
305--- tests/test_object.cpp 2011-11-11 02:50:19 +0000
306+++ tests/gtest-nuxcore-object.cpp 2012-02-26 02:38:17 +0000
307@@ -33,24 +33,24 @@
308 {
309 public:
310 OwnedObject(NUX_FILE_LINE_PROTO)
311- : nux::Object (true, NUX_FILE_LINE_PARAM)
312+ : nux::Object(true, NUX_FILE_LINE_PARAM)
313 {
314 }
315
316- ~OwnedObject () {}
317+ ~OwnedObject() {}
318
319- int array [ARRAY_SIZE];
320+ int array[ARRAY_SIZE];
321 };
322
323 class ChildOwnedObject: public OwnedObject
324 {
325 public:
326 ChildOwnedObject(NUX_FILE_LINE_PROTO)
327- : OwnedObject (NUX_FILE_LINE_PARAM)
328+ : OwnedObject(NUX_FILE_LINE_PARAM)
329 {
330 }
331
332- ~ChildOwnedObject () {}
333+ ~ChildOwnedObject() {}
334
335 int array [ARRAY_SIZE];
336 };
337@@ -60,11 +60,11 @@
338 {
339 public:
340 UnOwnedObject(NUX_FILE_LINE_PROTO)
341- : nux::Object (false, NUX_FILE_LINE_PARAM)
342+ : nux::Object(false, NUX_FILE_LINE_PARAM)
343 {
344 }
345
346- ~UnOwnedObject () {}
347+ ~UnOwnedObject() {}
348
349 int array [ARRAY_SIZE];
350 };
351@@ -84,7 +84,7 @@
352
353 TEST(TestObject, TestObject) {
354
355- OwnedObject *a = new OwnedObject (NUX_TRACKER_LOCATION);
356+ OwnedObject* a = new OwnedObject(NUX_TRACKER_LOCATION);
357 OwnedObject b(NUX_TRACKER_LOCATION);
358
359 EXPECT_THAT(a, NotNull());
360@@ -125,19 +125,14 @@
361
362 TEST(TestObject, TestObjectPtr) {
363
364- OwnedObject *a = new OwnedObject (NUX_TRACKER_LOCATION); // ref count = 1, owned
365+ OwnedObject* a = new OwnedObject(NUX_TRACKER_LOCATION); // ref count = 1, owned
366
367- nux::ObjectPtr<OwnedObject> object_ptr (a); // ref count = 2
368+ nux::ObjectPtr<OwnedObject> object_ptr(a); // ref count = 2
369
370 EXPECT_THAT(a->GetReferenceCount(), Eq(2));
371 EXPECT_FALSE(a->UnReference()); // ref count = 1
372 EXPECT_THAT(a->GetReferenceCount(), Eq(1));
373
374- // Calling UnReference repeatedly should not destroy the object when there
375- // are ObjectPtr's hosting it.
376- EXPECT_FALSE(a->UnReference());
377- EXPECT_THAT(a->GetReferenceCount(), Eq(1));
378-
379 object_ptr.Release();
380 }
381
382@@ -166,23 +161,19 @@
383
384 TEST(TestObject, TestObjectPtr1) {
385
386- ChildOwnedObject *c = new ChildOwnedObject (NUX_TRACKER_LOCATION); // ref count = 1, owned
387+ ChildOwnedObject* c = new ChildOwnedObject(NUX_TRACKER_LOCATION); // ref count = 1, owned
388
389- nux::ObjectPtr<OwnedObject> object_ptr0 (c); // ref count = 2
390+ nux::ObjectPtr<OwnedObject> object_ptr0(c); // ref count = 2
391
392 EXPECT_THAT(c->GetReferenceCount(), Eq(2));
393
394- nux::ObjectPtr<OwnedObject> object_ptr1 (object_ptr0); // ref count = 3
395+ nux::ObjectPtr<OwnedObject> object_ptr1(object_ptr0); // ref count = 3
396
397 EXPECT_THAT(c->GetReferenceCount(), Eq(3));
398
399 EXPECT_FALSE(c->UnReference()); // ref count = 2
400- EXPECT_FALSE(c->UnReference()); // ref count = 2
401- EXPECT_FALSE(c->UnReference()); // ref count = 2
402-
403- EXPECT_THAT(c->GetReferenceCount(), Eq(2));
404-
405- object_ptr1.Release ();
406+
407+ object_ptr1.Release();
408
409 EXPECT_THAT(c->GetReferenceCount(), Eq(1));
410
411
412=== renamed file 'tests/test_properties.cpp' => 'tests/gtest-nuxcore-properties.cpp'
413=== renamed file 'tests/test_rolling_file_appender.cpp' => 'tests/gtest-nuxcore-rolling-file-appender.cpp'

Subscribers

People subscribed via source and target branches

to all changes: