Skip to content

Commit d4cfb36

Browse files
committed
Test AddSource functionality for ListSelector
1 parent 20c6dc9 commit d4cfb36

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

test/+wt/+test/ListSelector.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ function setup(testCase)
3939

4040
% Set the initial items
4141
testCase.verifySetProperty("Items", testCase.ItemNames);
42+
43+
% Set callback
44+
testCase.Widget.ButtonPushedFcn = @(s,e)onCallbackTriggered(testCase,e);
45+
testCase.Widget.ValueChangedFcn = @(s,e)onCallbackTriggered(testCase,e);
46+
testCase.Widget.HighlightedValueChangedFcn = @(s,e)onCallbackTriggered(testCase,e);
4247

4348
end %function
4449

@@ -363,6 +368,29 @@ function testUserButtons(testCase)
363368
testCase.verifyNumElements(b, 2);
364369
testCase.press(b(1))
365370
testCase.press(b(2))
371+
372+
% Verify callbacks fired
373+
testCase.verifyEqual(testCase.CallbackCount, 2);
374+
375+
end %function
376+
377+
378+
379+
function testAddSource(testCase)
380+
381+
% Get the widget
382+
w = testCase.Widget;
383+
buttonGrid = testCase.Widget.ListButtons;
384+
button = buttonGrid.Button;
385+
386+
% Add User buttons
387+
w.AddSource = 'ButtonPushedFcn';
388+
389+
% Press the buttons
390+
testCase.press(button(1))
391+
392+
% Verify callbacks fired
393+
testCase.verifyEqual(testCase.CallbackCount, 1);
366394

367395
end %function
368396

0 commit comments

Comments
 (0)