Skip to content

Commit b69948f

Browse files
committed
test: In api-test app allow to read test suite from stdin
Allow to invoke as `./build/api-test-app <test-suite.example`.
1 parent 2608d97 commit b69948f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

test/api_test_app/main.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <cstdlib>
3434
#include <future>
3535
#include <ios>
36+
#include <unistd.h>
3637

3738
int main(int argc, char** argv)
3839
{
@@ -135,7 +136,36 @@ int main(int argc, char** argv)
135136
interfaces.emplace_back(std::make_unique<StatsDemo>());
136137
interfaces.emplace_back(std::make_unique<TextToSpeechDemo>());
137138

138-
if (appConfig.autoRun)
139+
if (!isatty(fileno(stdin)))
140+
{
141+
appConfig.autoRun = true;
142+
std::string line;
143+
while (std::getline(std::cin, line))
144+
{
145+
bool found = false;
146+
for (const auto& interface : interfaces)
147+
{
148+
for (const auto& method : interface->methods())
149+
{
150+
if (method == line)
151+
{
152+
interface->runOption(method);
153+
found = true;
154+
break;
155+
}
156+
}
157+
if (found)
158+
{
159+
break;
160+
}
161+
}
162+
if (!found)
163+
{
164+
std::cout << "Method not found: " << line << std::endl;
165+
}
166+
}
167+
}
168+
else if (appConfig.autoRun)
139169
{
140170
for (auto& interface : interfaces)
141171
{
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Accessibility.highContrastUI
2+
Device.chipsetId
3+
TextToSpeech.speak
4+
TextToSpeech.listVoices
5+
TextToSpeech.pause

0 commit comments

Comments
 (0)