MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / testProgressBar

Function testProgressBar

test/test_ProgressBar/TestProgressBar.cpp:121–215  ·  view source on GitHub ↗

* Test progress bar. */

Source from the content-addressed store, hash-verified

119 * Test progress bar.
120 */
121static void testProgressBar()
122{
123 YAGfxTest testGfx;
124 const int16_t POS_X = 2;
125 const int16_t POS_Y = 2;
126 ProgressBar progressBar(YAGfxTest::WIDTH, YAGfxTest::HEIGHT);
127 const char* WIDGET_NAME = "progressBarName";
128
129 /* Verify widget type name */
130 TEST_ASSERT_EQUAL_STRING(ProgressBar::WIDGET_TYPE, progressBar.getType());
131
132 /* No widget name is set, it must be empty. */
133 TEST_ASSERT_EQUAL_STRING("", progressBar.getName().c_str());
134
135 /* Set widget name and read back. */
136 progressBar.setName(WIDGET_NAME);
137 TEST_ASSERT_EQUAL_STRING(WIDGET_NAME, progressBar.getName().c_str());
138
139 /* Find widget with empty name.
140 * Expected: Not found
141 */
142 TEST_ASSERT_NULL(progressBar.find(""));
143
144 /* Find widget with its name.
145 * Expected: Widget is found
146 */
147 TEST_ASSERT_NOT_NULL(progressBar.find(WIDGET_NAME));
148 TEST_ASSERT_EQUAL_PTR(&progressBar, progressBar.find(WIDGET_NAME));
149
150 /* Default algorithm: progress bar */
151
152 /* Progress should be now 0% */
153 progressBar.update(testGfx);
154 TEST_ASSERT_TRUE(testGfx.verify(0, 0, testGfx.getWidth(), testGfx.getHeight(), ColorDef::BLACK));
155
156 /* Set progress bar to 50% */
157 progressBar.setProgress(50U);
158 progressBar.update(testGfx);
159 TEST_ASSERT_TRUE(testGfx.verify(0, 0, testGfx.getWidth() / 2u, testGfx.getHeight(), ColorDef::RED));
160 TEST_ASSERT_TRUE(testGfx.verify(testGfx.getWidth() / 2u, 0, testGfx.getWidth() / 2u, testGfx.getHeight(), ColorDef::BLACK));
161
162 /* Set progress bar to 100% */
163 progressBar.setProgress(100U);
164 progressBar.update(testGfx);
165 TEST_ASSERT_TRUE(testGfx.verify(0, 0, testGfx.getWidth(), testGfx.getHeight(), ColorDef::RED));
166
167 /* Clear display */
168 testGfx.fill(ColorDef::BLACK);
169
170 /* Widget must be moveable */
171 progressBar.move(POS_X, POS_Y);
172 progressBar.setWidth(testGfx.getWidth() - POS_X);
173 progressBar.setHeight(testGfx.getHeight() - POS_Y);
174 progressBar.setProgress(100U);
175 progressBar.update(testGfx);
176 TEST_ASSERT_TRUE(testGfx.verify(POS_X, POS_Y, testGfx.getWidth() - POS_X, testGfx.getHeight() - POS_Y, ColorDef::RED));
177 progressBar.move(0, 0);
178

Callers

nothing calls this directly

Calls 15

c_strMethod · 0.80
verifyMethod · 0.80
fillMethod · 0.80
moveMethod · 0.80
setAlgoMethod · 0.80
getTypeMethod · 0.45
getNameMethod · 0.45
setNameMethod · 0.45
findMethod · 0.45
updateMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected