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
=== modified file 'Nux/View.cpp'
--- Nux/View.cpp 2012-02-22 16:41:47 +0000
+++ Nux/View.cpp 2012-02-26 02:38:17 +0000
@@ -36,9 +36,6 @@
36 view_layout_ = NULL;36 view_layout_ = NULL;
37 draw_cmd_queued_ = false;37 draw_cmd_queued_ = false;
38 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);38 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
39
40 // Set widget default size;
41 SetMinimumSize(DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT);
42 }39 }
4340
44 View::~View()41 View::~View()
4542
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2012-02-23 06:49:05 +0000
+++ tests/Makefile.am 2012-02-26 02:38:17 +0000
@@ -1,8 +1,7 @@
1if BUILD_TESTS1if BUILD_TESTS
2check_PROGRAMS = \2check_PROGRAMS = \
3 test-nux \
4 gtest-nux \3 gtest-nux \
5 gtest-nux-core \4 gtest-nuxcore \
6 test-graphics-display \5 test-graphics-display \
7 test-empty-window \6 test-empty-window \
8 xtest-button \7 xtest-button \
@@ -18,45 +17,44 @@
18 xtest-focus-on-mouse-enter 17 xtest-focus-on-mouse-enter
1918
20# Please keep alphabetical19# Please keep alphabetical
21test_nux_SOURCES = \20# test_nux_SOURCES = \
22 test-canvas.cpp \21# test-canvas.cpp \
23 test-nux.cpp \22# test-nux.cpp \
24 test-system.cpp23# test-system.cpp
2524
26test_nux_CPPFLAGS = \25#test_nux_CPPFLAGS = \
27 -I$(srcdir) \26# -I$(srcdir) \
28 -I$(top_srcdir) \27# -I$(top_srcdir) \
29 -DPREFIX=\""$(prefix)"\" \28# -DPREFIX=\""$(prefix)"\" \
30 -DLIBDIR=\""$(libdir)"\" \29# -DLIBDIR=\""$(libdir)"\" \
31 -DDATADIR=\""$(datadir)"\" \30# -DDATADIR=\""$(datadir)"\" \
32 -DG_LOG_DOMAIN=\"NuxTests\" \31# -DG_LOG_DOMAIN=\"NuxTests\" \
33 -DTESTDIR=\""$(top_srcdir)/tests"\" \32# -DTESTDIR=\""$(top_srcdir)/tests"\" \
34 $(GCC_FLAGS) \33# $(GCC_FLAGS) \
35 $(NUX_CORE_CFLAGS) \34# $(NUX_CORE_CFLAGS) \
36 $(NUX_EXAMPLES_CFLAGS) \35# $(NUX_EXAMPLES_CFLAGS) \
37 $(NUX_CFLAGS) \36# $(NUX_CFLAGS) \
38 $(MAINTAINER_CFLAGS)37# $(MAINTAINER_CFLAGS)
3938
40test_nux_LDADD = \39#test_nux_LDADD = \
41 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \40# $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
42 $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \41# $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \
43 $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \42# $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \
44 $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \43# $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \
45 $(NUX_LIBS)44# $(NUX_LIBS)
4645
47gtest_nux_core_SOURCES = \46gtest_nuxcore_SOURCES = \
48 Helpers.h \47 Helpers.h \
49 Helpers.cpp \48 Helpers.cpp \
49 gtest-nuxcore-async-file-writer.cpp \
50 gtest-nuxcore-color.cpp \50 gtest-nuxcore-color.cpp \
51 test_object.cpp \51 gtest-nuxcore-logger.cpp \
52 test_main.cpp \52 gtest-nuxcore-main.cpp \
53 test_async_file_writer.cpp \53 gtest-nuxcore-object.cpp \
54 test_logger.cpp \54 gtest-nuxcore-properties.cpp \
55 test_cairo_wrapper.cpp \55 gtest-nuxcore-rolling-file-appender.cpp
56 test_properties.cpp \
57 test_rolling_file_appender.cpp
5856
59gtest_nux_core_CPPFLAGS = \57gtest_nuxcore_CPPFLAGS = \
60 -I$(srcdir) \58 -I$(srcdir) \
61 -I$(top_srcdir) \59 -I$(top_srcdir) \
62 -DPREFIX=\""$(prefix)"\" \60 -DPREFIX=\""$(prefix)"\" \
@@ -70,24 +68,26 @@
70 $(NUX_CFLAGS) \68 $(NUX_CFLAGS) \
71 $(MAINTAINER_CFLAGS)69 $(MAINTAINER_CFLAGS)
7270
73gtest_nux_core_LDADD = \71gtest_nuxcore_LDADD = \
74 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \72 $(top_builddir)/NuxCore/libnux-core-@NUX_API_VERSION@.la \
75 $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \73 $(top_builddir)/NuxImage/libnux-image-@NUX_API_VERSION@.la \
76 $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \74 $(top_builddir)/NuxGraphics/libnux-graphics-@NUX_API_VERSION@.la \
77 $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \75 $(top_builddir)/Nux/libnux-@NUX_API_VERSION@.la \
78 $(NUX_LIBS)76 $(NUX_LIBS)
7977
80gtest_nux_core_LDFLAGS = \78gtest_nuxcore_LDFLAGS = \
81 -lpthread -lgtest -lgmock \79 -lpthread -lgtest -lgmock \
82 -lboost_filesystem -lboost_system80 -lboost_filesystem -lboost_system
8381
84gtest_nux_SOURCES = \82gtest_nux_SOURCES = \
85 test-nux-main.cpp \83 gtest-nux-area.cpp \
86 test-nux-metrics.cpp \84 gtest-nux-cairo-wrapper.cpp \
87 test-nux-statictext.cpp \85 gtest-nux-emmetrics.cpp \
86 gtest-nux-main.cpp \
87 gtest-nux-statictext.cpp \
88 gtest-nux-view.cpp \
88 gtest-nux-windowcompositor.cpp \89 gtest-nux-windowcompositor.cpp \
89 test-nux-windowthread.cpp90 gtest-nux-windowthread.cpp
90
9191
92gtest_nux_CPPFLAGS = \92gtest_nux_CPPFLAGS = \
93 -I$(srcdir) \93 -I$(srcdir) \
@@ -243,14 +243,14 @@
243check-local: test gtest test-apps243check-local: test gtest test-apps
244244
245test:245test:
246 @gtester --verbose -k -o=test-nux-results.xml ./test-nux246 @gtester --verbose -k -o=gtest-nux-results.xml ./gtest-nux
247247
248gtest: gtest-nux-core gtest-nux248gtest: gtest-nuxcore gtest-nux
249 ./gtest-nux-core249 ./gtest-nuxcore
250 ./gtest-nux250 ./gtest-nux
251251
252check-headless: gtest-nux-core252check-headless: gtest-nuxcore
253 @gtester --verbose -k -o=test-nux-results.xml ./gtest-nux-core253 @gtester --verbose -k -o=test-nux-results.xml ./gtest-nuxcore
254254
255test-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-directions255test-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
256 ./test-graphics-display256 ./test-graphics-display
257257
=== added file 'tests/gtest-nux-area.cpp'
--- tests/gtest-nux-area.cpp 1970-01-01 00:00:00 +0000
+++ tests/gtest-nux-area.cpp 2012-02-26 02:38:17 +0000
@@ -0,0 +1,74 @@
1#include <string>
2#include <fstream>
3
4#include <iostream>
5#include <gmock/gmock.h>
6#include <boost/filesystem.hpp>
7#include <glib.h>
8
9#include "Nux/Nux.h"
10#include "Nux/StaticText.h"
11#include "Nux/ProgramFramework/TestView.h"
12
13
14using namespace testing;
15
16namespace {
17
18TEST(TestArea, TestAreaSize)
19{
20 nux::NuxInitialize(0);
21 nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Area Test", 300, 200,
22 nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
23
24 nux::TestView* test_view = new nux::TestView("");
25
26 EXPECT_EQ(test_view->GetMinimumWidth(), nux::AREA_MIN_WIDTH);
27 EXPECT_EQ(test_view->GetMaximumWidth(), nux::AREA_MAX_WIDTH);
28 EXPECT_EQ(test_view->GetMinimumHeight(), nux::AREA_MIN_HEIGHT);
29 EXPECT_EQ(test_view->GetMaximumHeight(), nux::AREA_MAX_HEIGHT);
30
31 test_view->SetMinimumWidth(100);
32 EXPECT_EQ(test_view->GetMinimumWidth(), 100);
33
34 test_view->SetMaximumWidth(1111);
35 EXPECT_EQ(test_view->GetMaximumWidth(), 1111);
36
37 test_view->SetMinimumHeight(123);
38 EXPECT_EQ(test_view->GetMinimumHeight(), 123);
39
40 test_view->SetMaximumHeight(1234);
41 EXPECT_EQ(test_view->GetMaximumHeight(), 1234);
42
43 test_view->SetMaximumSize(4321, 1234);
44 test_view->SetMinimumSize(123, 432);
45
46 EXPECT_EQ(test_view->GetMinimumWidth(), 123);
47 EXPECT_EQ(test_view->GetMaximumWidth(), 4321);
48 EXPECT_EQ(test_view->GetMinimumHeight(), 432);
49 EXPECT_EQ(test_view->GetMaximumHeight(), 1234);
50
51 test_view->UnReference();
52 delete wnd_thread;
53}
54
55TEST(TestArea, TestAreaGeometry)
56{
57 nux::NuxInitialize(0);
58 nux::WindowThread *wnd_thread = nux::CreateNuxWindow("Area Test", 300, 200,
59 nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
60
61 nux::TestView* test_view = new nux::TestView("");
62
63 static_cast<nux::Area*>(test_view)->SetGeometry(0, 0, 100, 100);
64
65 EXPECT_EQ(test_view->GetBaseX(), 0);
66 EXPECT_EQ(test_view->GetBaseX(), 0);
67 EXPECT_EQ(test_view->GetBaseWidth(), 100);
68 EXPECT_EQ(test_view->GetBaseHeight(), 100);
69
70
71 test_view->UnReference();
72 delete wnd_thread;
73}
74}
075
=== renamed file 'tests/test_cairo_wrapper.cpp' => 'tests/gtest-nux-cairo-wrapper.cpp'
=== renamed file 'tests/test-nux-metrics.cpp' => 'tests/gtest-nux-emmetrics.cpp'
=== renamed file 'tests/test-nux-main.cpp' => 'tests/gtest-nux-main.cpp'
=== renamed file 'tests/test-nux-statictext.cpp' => 'tests/gtest-nux-statictext.cpp'
=== added file 'tests/gtest-nux-view.cpp'
--- tests/gtest-nux-view.cpp 1970-01-01 00:00:00 +0000
+++ tests/gtest-nux-view.cpp 2012-02-26 02:38:17 +0000
@@ -0,0 +1,37 @@
1#include <string>
2#include <fstream>
3
4#include <iostream>
5#include <gmock/gmock.h>
6#include <boost/filesystem.hpp>
7#include <glib.h>
8
9#include "Nux/Nux.h"
10#include "Nux/StaticText.h"
11#include "Nux/ProgramFramework/TestView.h"
12
13
14using namespace testing;
15
16namespace {
17
18TEST(TestView, TestViewEnable)
19{
20 nux::NuxInitialize(0);
21 nux::WindowThread *wnd_thread = nux::CreateNuxWindow("View Test", 300, 200,
22 nux::WINDOWSTYLE_NORMAL, NULL, false, NULL, NULL);
23
24 nux::TestView* test_view = new nux::TestView("");
25
26 test_view->EnableView();
27 EXPECT_TRUE(test_view->IsViewEnabled());
28
29 test_view->DisableView();
30 EXPECT_FALSE(test_view->IsViewEnabled());
31
32
33 test_view->UnReference();
34 delete wnd_thread;
35}
36
37}
038
=== renamed file 'tests/test-nux-windowthread.cpp' => 'tests/gtest-nux-windowthread.cpp'
=== renamed file 'tests/test_async_file_writer.cpp' => 'tests/gtest-nuxcore-async-file-writer.cpp'
=== renamed file 'tests/test_logger.cpp' => 'tests/gtest-nuxcore-logger.cpp'
--- tests/test_logger.cpp 2011-08-03 04:26:34 +0000
+++ tests/gtest-nuxcore-logger.cpp 2012-02-26 02:38:17 +0000
@@ -238,7 +238,7 @@
238 std::string result = out.str();238 std::string result = out.str();
239239
240 EXPECT_THAT(result, StartsWith("DEBUG"));240 EXPECT_THAT(result, StartsWith("DEBUG"));
241 EXPECT_THAT(result, HasSubstr(" test.module test_logger.cpp"));241 EXPECT_THAT(result, HasSubstr(" test.module gtest-nuxcore-logger.cpp"));
242 EXPECT_THAT(result, EndsWith("1 Is output now.\n"));242 EXPECT_THAT(result, EndsWith("1 Is output now.\n"));
243 // Also only one line.243 // Also only one line.
244 EXPECT_THAT(counter, Eq(1));244 EXPECT_THAT(counter, Eq(1));
245245
=== renamed file 'tests/test_main.cpp' => 'tests/gtest-nuxcore-main.cpp'
=== renamed file 'tests/test_object.cpp' => 'tests/gtest-nuxcore-object.cpp'
--- tests/test_object.cpp 2011-11-11 02:50:19 +0000
+++ tests/gtest-nuxcore-object.cpp 2012-02-26 02:38:17 +0000
@@ -33,24 +33,24 @@
33{33{
34public:34public:
35 OwnedObject(NUX_FILE_LINE_PROTO)35 OwnedObject(NUX_FILE_LINE_PROTO)
36 : nux::Object (true, NUX_FILE_LINE_PARAM)36 : nux::Object(true, NUX_FILE_LINE_PARAM)
37 {37 {
38 }38 }
3939
40 ~OwnedObject () {}40 ~OwnedObject() {}
4141
42 int array [ARRAY_SIZE];42 int array[ARRAY_SIZE];
43};43};
4444
45class ChildOwnedObject: public OwnedObject45class ChildOwnedObject: public OwnedObject
46{46{
47public:47public:
48 ChildOwnedObject(NUX_FILE_LINE_PROTO)48 ChildOwnedObject(NUX_FILE_LINE_PROTO)
49 : OwnedObject (NUX_FILE_LINE_PARAM)49 : OwnedObject(NUX_FILE_LINE_PARAM)
50 {50 {
51 }51 }
5252
53 ~ChildOwnedObject () {}53 ~ChildOwnedObject() {}
5454
55 int array [ARRAY_SIZE];55 int array [ARRAY_SIZE];
56};56};
@@ -60,11 +60,11 @@
60{60{
61public:61public:
62 UnOwnedObject(NUX_FILE_LINE_PROTO)62 UnOwnedObject(NUX_FILE_LINE_PROTO)
63 : nux::Object (false, NUX_FILE_LINE_PARAM)63 : nux::Object(false, NUX_FILE_LINE_PARAM)
64 {64 {
65 }65 }
6666
67 ~UnOwnedObject () {}67 ~UnOwnedObject() {}
6868
69 int array [ARRAY_SIZE];69 int array [ARRAY_SIZE];
70};70};
@@ -84,7 +84,7 @@
8484
85TEST(TestObject, TestObject) {85TEST(TestObject, TestObject) {
8686
87 OwnedObject *a = new OwnedObject (NUX_TRACKER_LOCATION);87 OwnedObject* a = new OwnedObject(NUX_TRACKER_LOCATION);
88 OwnedObject b(NUX_TRACKER_LOCATION);88 OwnedObject b(NUX_TRACKER_LOCATION);
8989
90 EXPECT_THAT(a, NotNull());90 EXPECT_THAT(a, NotNull());
@@ -125,19 +125,14 @@
125125
126TEST(TestObject, TestObjectPtr) {126TEST(TestObject, TestObjectPtr) {
127127
128 OwnedObject *a = new OwnedObject (NUX_TRACKER_LOCATION); // ref count = 1, owned128 OwnedObject* a = new OwnedObject(NUX_TRACKER_LOCATION); // ref count = 1, owned
129129
130 nux::ObjectPtr<OwnedObject> object_ptr (a); // ref count = 2130 nux::ObjectPtr<OwnedObject> object_ptr(a); // ref count = 2
131131
132 EXPECT_THAT(a->GetReferenceCount(), Eq(2));132 EXPECT_THAT(a->GetReferenceCount(), Eq(2));
133 EXPECT_FALSE(a->UnReference()); // ref count = 1133 EXPECT_FALSE(a->UnReference()); // ref count = 1
134 EXPECT_THAT(a->GetReferenceCount(), Eq(1));134 EXPECT_THAT(a->GetReferenceCount(), Eq(1));
135135
136 // Calling UnReference repeatedly should not destroy the object when there
137 // are ObjectPtr's hosting it.
138 EXPECT_FALSE(a->UnReference());
139 EXPECT_THAT(a->GetReferenceCount(), Eq(1));
140
141 object_ptr.Release();136 object_ptr.Release();
142}137}
143138
@@ -166,23 +161,19 @@
166161
167TEST(TestObject, TestObjectPtr1) {162TEST(TestObject, TestObjectPtr1) {
168163
169 ChildOwnedObject *c = new ChildOwnedObject (NUX_TRACKER_LOCATION); // ref count = 1, owned164 ChildOwnedObject* c = new ChildOwnedObject(NUX_TRACKER_LOCATION); // ref count = 1, owned
170165
171 nux::ObjectPtr<OwnedObject> object_ptr0 (c); // ref count = 2166 nux::ObjectPtr<OwnedObject> object_ptr0(c); // ref count = 2
172167
173 EXPECT_THAT(c->GetReferenceCount(), Eq(2));168 EXPECT_THAT(c->GetReferenceCount(), Eq(2));
174169
175 nux::ObjectPtr<OwnedObject> object_ptr1 (object_ptr0); // ref count = 3170 nux::ObjectPtr<OwnedObject> object_ptr1(object_ptr0); // ref count = 3
176171
177 EXPECT_THAT(c->GetReferenceCount(), Eq(3));172 EXPECT_THAT(c->GetReferenceCount(), Eq(3));
178173
179 EXPECT_FALSE(c->UnReference()); // ref count = 2174 EXPECT_FALSE(c->UnReference()); // ref count = 2
180 EXPECT_FALSE(c->UnReference()); // ref count = 2175
181 EXPECT_FALSE(c->UnReference()); // ref count = 2176 object_ptr1.Release();
182
183 EXPECT_THAT(c->GetReferenceCount(), Eq(2));
184
185 object_ptr1.Release ();
186177
187 EXPECT_THAT(c->GetReferenceCount(), Eq(1));178 EXPECT_THAT(c->GetReferenceCount(), Eq(1));
188179
189180
=== renamed file 'tests/test_properties.cpp' => 'tests/gtest-nuxcore-properties.cpp'
=== 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: