aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/test/wx_basic_SUITE.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2015-05-19 10:01:42 +0200
committerDan Gudmundsson <[email protected]>2015-06-01 13:07:32 +0200
commit5b2ad02d50a23b5e82f9ebbc644622e42199ea95 (patch)
treefead9dbe4e5365808940e3e301c76745e4f976da /lib/wx/test/wx_basic_SUITE.erl
parent8260f916c2ab9b9dff9752b47e47d07ac3d95c92 (diff)
downloadotp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.tar.gz
otp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.tar.bz2
otp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.zip
wx: Fix bad float in return values
To many floats in return value could cause a reallocation and pointers to reallocated data. Fix it by ensuring that the temp float array is large enough before add values to it.
Diffstat (limited to 'lib/wx/test/wx_basic_SUITE.erl')
-rw-r--r--lib/wx/test/wx_basic_SUITE.erl31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/wx/test/wx_basic_SUITE.erl b/lib/wx/test/wx_basic_SUITE.erl
index e3bbb21a23..2a17cc3ab9 100644
--- a/lib/wx/test/wx_basic_SUITE.erl
+++ b/lib/wx/test/wx_basic_SUITE.erl
@@ -271,13 +271,19 @@ wx_misc(_Config) ->
wx:destroy().
-%% Check that all the data_types works in communication
+%% Check that all the data_types works in communication
%% between erlang and c++ thread.
data_types(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
data_types(_Config) ->
Wx = ?mr(wx_ref, wx:new()),
-
+
Frame = wxFrame:new(Wx, 1, "Data Types"),
+ wxFrame:connect(Frame, show),
+ wxFrame:show(Frame),
+ receive #wx{event=#wxShow{}} -> ok
+ after 1000 -> exit(show_timeout)
+ end,
+
CDC = wxClientDC:new(Frame),
%% From wx.erl
@@ -292,16 +298,31 @@ data_types(_Config) ->
?m(ok, wxDC:setUserScale(CDC, 123.45, 234.67)),
?m({123.45,234.67}, wxDC:getUserScale(CDC)),
+ %% Array of doubles
+ try wxGraphicsContext:create(CDC) of
+ GC ->
+ wxGraphicsContext:setFont(GC, ?wxITALIC_FONT, {0, 0, 50}),
+ Ws = wxGraphicsContext:getPartialTextExtents(GC, "a String With More Than 16 Characters"),
+ _ = lists:foldl(fun(Width, {Index, Acc}) ->
+ if Width >= Acc, Width < 500 -> {Index+1, Width};
+ true -> throw({bad_float, Width, Index, Acc})
+ end
+ end, {0,0.0}, Ws),
+ ok
+ catch _:_ -> %% GC not supported on this platform
+ ok
+ end,
+
%% Colors input is 3 or 4 tuple, returns are 4 tuples
?m(ok, wxDC:setTextForeground(CDC, {100,10,1})),
?m({100,10,1,255}, wxDC:getTextForeground(CDC)),
?m(ok, wxDC:setTextForeground(CDC, {100,10,1,43})),
?m({100,10,1,43}, wxDC:getTextForeground(CDC)),
- %% Bool
+ %% Bool
?m(ok, wxDC:setAxisOrientation(CDC, true, false)),
?m(true, is_boolean(wxDC:isOk(CDC))),
-
+
%% wxCoord
?m(true, is_integer(wxDC:maxX(CDC))),
@@ -309,7 +330,7 @@ data_types(_Config) ->
?m({_,_}, wxWindow:getSize(Frame)),
%% DateTime
- DateTime = {Date, _Time} = calendar:now_to_datetime(erlang:now()),
+ DateTime = {Date, _Time} = calendar:now_to_datetime(os:timestamp()),
io:format("DateTime ~p ~n",[DateTime]),
Cal = ?mt(wxCalendarCtrl, wxCalendarCtrl:new(Frame, ?wxID_ANY, [{date,DateTime}])),
?m({Date,_}, wxCalendarCtrl:getDate(Cal)),