Skip to content

Commit 7426cd7

Browse files
authored
Merge pull request #2 from mathworks/tests
Tests
2 parents 8097174 + ded7ae0 commit 7426cd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+959
-53
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ The license is available in the [license.txt](license.txt) file in this GitHub r
3030
## Community Support
3131
[MATLAB Central](https://www.mathworks.com/matlabcentral)
3232

33-
Copyright 2022 The MathWorks, Inc.
33+
Copyright 2021-2025 The MathWorks, Inc.

code/Component.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
classdef ( Abstract ) Component < matlab.ui.componentcontainer.ComponentContainer
22
%COMPONENT Superclass for implementing views and controllers.
3-
%
4-
% Copyright 2021-2022 The MathWorks, Inc.
3+
4+
% Copyright 2021-2025 The MathWorks, Inc.
55

66
properties ( SetAccess = immutable, GetAccess = protected )
77
% Application data model.
8-
Model(1, 1) Model
8+
Model(:, 1) Model {mustBeScalarOrEmpty}
99
end % properties ( SetAccess = immutable, GetAccess = protected )
1010

1111
methods
1212

1313
function obj = Component( model )
1414
%COMPONENT Component constructor.
1515

16-
arguments
16+
arguments ( Input )
1717
model(1, 1) Model
18-
end % arguments
18+
end % arguments ( Input )
1919

2020
% Do not create a default figure parent for the component, and
2121
% ensure that the component spans its parent. By default,

code/Controller.m

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,70 @@
11
classdef Controller < Component
22
%CONTROLLER Provides an interactive control to generate new data.
3-
%
4-
% Copyright 2021-2022 The MathWorks, Inc.
5-
3+
4+
% Copyright 2021-2025 The MathWorks, Inc.
5+
6+
properties ( GetAccess = ?matlab.unittest.TestCase, ...
7+
SetAccess = private )
8+
% Push button for generating new data.
9+
Button(:, 1) matlab.ui.control.Button {mustBeScalarOrEmpty}
10+
end % properties ( GetAccess = ?matlab.unittest.TestCase, ...
11+
% SetAccess = private )
12+
613
methods
7-
14+
815
function obj = Controller( model, namedArgs )
916
% CONTROLLER Controller constructor.
10-
11-
arguments
17+
18+
arguments ( Input )
1219
model(1, 1) Model
1320
namedArgs.?Controller
14-
end % arguments
15-
21+
end % arguments ( Input )
22+
1623
% Call the superclass constructor.
1724
obj@Component( model )
18-
25+
1926
% Set any user-specified properties.
2027
set( obj, namedArgs )
21-
28+
2229
end % constructor
23-
30+
2431
end % methods
25-
32+
2633
methods ( Access = protected )
27-
34+
2835
function setup( obj )
2936
%SETUP Initialize the controller.
30-
37+
3138
% Create grid and button.
3239
g = uigridlayout( ...
3340
"Parent", obj, ...
3441
"RowHeight", "1x", ...
3542
"ColumnWidth", "1x", ...
3643
"Padding", 0 );
37-
uibutton( ...
44+
obj.Button = uibutton( ...
3845
"Parent", g, ...
3946
"Text", "Generate Random Data", ...
4047
"ButtonPushedFcn", @obj.onButtonPushed );
41-
48+
4249
end % setup
43-
50+
4451
function update( ~ )
45-
%UPDATE Update the controller. This method is empty because
52+
%UPDATE Update the controller. This method is empty because
4653
%there are no public properties of the controller.
47-
54+
4855
end % update
49-
56+
5057
end % methods ( Access = protected )
51-
58+
5259
methods ( Access = private )
53-
60+
5461
function onButtonPushed( obj, ~, ~ )
55-
62+
5663
% Invoke the random() method of the model.
5764
random( obj.Model )
58-
65+
5966
end % onButtonPushed
60-
67+
6168
end % methods ( Access = private )
62-
69+
6370
end % classdef

code/Model.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef Model < handle
22
%MODEL Application data model.
3-
%
4-
% Copyright 2021-2022 The MathWorks, Inc.
3+
4+
% Copyright 2021-2025 The MathWorks, Inc.
55

66
properties ( SetAccess = private )
77
% Application data.

code/View.m

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
classdef View < Component
22
%VIEW Visualizes the data, responding to any relevant model events.
3-
%
4-
% Copyright 2021-2022 The MathWorks, Inc.
3+
4+
% Copyright 2021-2025 The MathWorks, Inc.
5+
6+
properties
7+
% Line width.
8+
LineWidth(1, 1) double {mustBePositive, mustBeFinite} = 1.5
9+
% Line color.
10+
LineColor {validatecolor} = "k"
11+
end % properties
12+
13+
properties ( GetAccess = ?matlab.unittest.TestCase, ...
14+
SetAccess = private )
15+
% Line object used to visualize the model data.
16+
Line(:, 1) matlab.graphics.primitive.Line {mustBeScalarOrEmpty}
17+
end % properties ( GetAccess = ?matlab.unittest.TestCase, ...
18+
% SetAccess = private )
519

620
properties ( Access = private )
7-
% Line object used to visualize the model data.
8-
Line(1, 1) matlab.graphics.primitive.Line
921
% Listener object used to respond dynamically to model events.
1022
Listener(:, 1) event.listener {mustBeScalarOrEmpty}
1123
end % properties ( Access = private )
@@ -15,10 +27,10 @@
1527
function obj = View( model, namedArgs )
1628
%VIEW View constructor.
1729

18-
arguments
30+
arguments ( Input )
1931
model(1, 1) Model
2032
namedArgs.?View
21-
end % arguments
33+
end % arguments ( Input )
2234

2335
% Call the superclass constructor.
2436
obj@Component( model )
@@ -55,9 +67,12 @@ function setup( obj )
5567

5668
end % setup
5769

58-
function update( ~ )
59-
%UPDATE Update the view. This method is empty because there are
60-
%no public properties of the view.
70+
function update( obj )
71+
%UPDATE Update the view in response to changes in the public
72+
%properties.
73+
74+
set( obj.Line, "LineWidth", obj.LineWidth, ...
75+
"Color", obj.LineColor )
6176

6277
end % update
6378

code/launchMVCApp.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
function varargout = launchMVCApp( f )
22
%LAUNCHMVCAPP Launch the small MVC application.
3-
%
4-
% Copyright 2021-2022 The MathWorks, Inc.
53

6-
arguments
4+
% Copyright 2021-2025 The MathWorks, Inc.
5+
6+
arguments ( Input )
77
f(1, 1) matlab.ui.Figure = uifigure()
8-
end % arguments
8+
end % arguments ( Input )
9+
10+
% Output check.
11+
nargoutchk( 0, 1 )
912

1013
% Rename figure.
1114
f.Name = "Small MVC App";
@@ -27,7 +30,7 @@
2730

2831
% Create toolbar to reset the model.
2932
icon = fullfile( matlabroot, ...
30-
"toolbox", "matlab", "icons", "tool_rotate_3d.png" );
33+
"toolbox", "matlab", "icons", "tool_rotate_3d.png" );
3134
tb = uitoolbar( "Parent", f );
3235
uipushtool( ...
3336
"Parent", tb, ...
@@ -37,15 +40,14 @@
3740

3841
function onReset( ~, ~ )
3942
%ONRESET Callback function for the toolbar reset button.
40-
43+
4144
% Reset the model.
4245
reset( m )
43-
46+
4447
end % onReset
4548

4649
% Return the figure handle if requested.
47-
if nargout > 0
48-
nargoutchk( 1, 1 )
50+
if nargout == 1
4951
varargout{1} = f;
5052
end % if
5153

license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2021, The MathWorks, Inc.
1+
Copyright (c) 2021-2025, The MathWorks, Inc.
22
All rights reserved.
33
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
44
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info Ref="tests" Type="Relative"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="85b5723a-0b1d-441f-ae27-f282d3456b06" type="Reference"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="design"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="IsEquivalentText.m" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="1" type="DIR_SIGNIFIER"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="design"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="NotifiesEvent.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="design"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="IsEqualVector.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="design"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="FigureFixture.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="test"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="tModel.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="test"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="tComponent.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="test"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="tView.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="test"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="tApp.m" type="File"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="test"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="tController.m" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Info location="tests" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info autoOpenCoverage="true" coverageMode="MCDC" isCoverageEnabled="true" isGenCoverageEnabled="false"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="MLTestManagerCoverageSettings" type="Files"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="1" type="DIR_SIGNIFIER"/>

0 commit comments

Comments
 (0)