Skip to content

Commit 9fcab72

Browse files
committed
unit test fixes for DatetimeSelector
1 parent 2b1296b commit 9fcab72

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

test/+wt/+test/DatetimeSelector.m

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ function testTimeZoneName(testCase)
171171
testCase.verifyTimeZoneDisplay();
172172

173173
% Verify the Value field was updated
174-
actValue = string(w.Value.TimeZone);
175-
testCase.verifyMatches(actValue, expValue)
176-
174+
testCase.verifyValueTimeZone(expValue)
175+
177176
end %function
178177

179178

@@ -322,18 +321,62 @@ function verifyTimeZoneDisplay(testCase, expVal)
322321
expVal (1,1) string = testCase.Widget.Value.TimeZone
323322
end
324323

324+
import matlab.unittest.constraints.Eventually
325+
import matlab.unittest.constraints.IsEqualTo
326+
325327
% Give a moment for any display updates
326-
pause(0.01);
327-
drawnow
328+
% pause(0.01);
329+
% drawnow
330+
%
331+
% % Verify correct timezone is selected
332+
% actVal = string(testCase.Widget.TimeZoneControl.Value);
333+
% testCase.verifyEqual(actVal, expVal);
334+
335+
% % Verify the correct timezone
336+
% testCase.verifyThat(...
337+
% @()getTimeZoneFromComponentDateTime(testCase.Widget.TimeZoneControl,"Value"),...
338+
% Eventually(IsEqualTo(expVal), "WithTimeoutOf", 5));'
339+
340+
testCase.verifyPropertyValue(testCase.Widget.TimeZoneControl, "Value", expVal);
341+
342+
end %function
343+
344+
345+
function verifyValueTimeZone(testCase, expVal)
346+
% Verify the time zone in Value matches the expected value
328347

329-
% Verify correct timezone is selected
330-
actVal = string(testCase.Widget.TimeZoneControl.Value);
331-
testCase.verifyEqual(actVal, expVal);
348+
arguments
349+
testCase
350+
expVal (1,1) string
351+
end
352+
353+
import matlab.unittest.constraints.Eventually
354+
import matlab.unittest.constraints.IsEqualTo
355+
356+
% Verify the correct timezone
357+
testCase.verifyThat(...
358+
@()getTimeZoneFromComponentDateTime(testCase.Widget,"Value"),...
359+
Eventually(IsEqualTo(expVal), "WithTimeoutOf", 5));
332360

333361
end %function
334362

363+
% function verifyTimeZone
364+
335365
end %methods
336366

337367

338368
end %classdef
339369

370+
371+
%% Helper functions
372+
function tz = getTimeZoneFromComponentDateTime(comp, propName)
373+
374+
arguments
375+
comp (1,1) matlab.graphics.Graphics
376+
propName (1,1) string
377+
end
378+
379+
tz = string(comp.(propName).TimeZone);
380+
381+
end %function
382+

0 commit comments

Comments
 (0)