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