Fixes to TTS 44/205544/6
authorAdrian Wojciechowski <a.wojciecho3@partner.samsung.com>
Tue, 7 May 2019 08:59:31 +0000 (10:59 +0200)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 16 May 2019 09:31:20 +0000 (11:31 +0200)
Change-Id: If0ee5e6d2eb140a54ddba45fd4ca253f58928ac4

src/batch/BatchRunner.cpp
src/batch/BatchRunner.hpp
src/batch/Dlog.cpp

index c8b43c9..fb0d4b6 100644 (file)
@@ -612,23 +612,10 @@ public:
        WaitTTS(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string pattern)
                : PredicateWaitInterface(executor, timeout)
        {
-               std::regex regex;
-               if (!pattern.empty()) {
-                       try {
-                               regex = std::regex {
-                                       pattern,
-                                       std::regex_constants::nosubs |
-                                       std::regex_constants::optimize |
-                                       std::regex_constants::ECMAScript
-                               };
-                       } catch (...) {
-                               throw EvaluationFailure{} << "invalid regex pattern '" << pattern << "'";
-                       }
-               }
                {
                        auto h = self->ttsInfo.lock();
                        if (!pattern.empty())
-                               h->searchLine = std::move(regex);
+                               h->searchLine = std::move(pattern);
                        h->mode = BatchExecutor::TTSInfo::Mode::search;
                }
                this->pattern = std::move(pattern);
@@ -981,21 +968,25 @@ static void threadFunc(StatPtr result, std::unique_ptr<BatchExecutor> exec, std:
                });
        }
        if (hasContext) {
-               auto ttsMainRegex = std::regex {
-                       "^D/SCREEN-READER[^>]*?> READ COMMAND PARAMS, TEXT: (.*?), DISCARDABLE: 0",
-                       std::regex_constants::optimize | std::regex_constants::ECMAScript
-               };
-               auto ttsDlogHandler = dlog.registerCallback([&exec, ttsMainRegex = std::move(ttsMainRegex)](const std::string & txt) {
+               auto ttsDlogHandler = dlog.registerCallback([&exec](const std::string & txt) {
                        auto h = exec->ttsInfo.lock();
                        if (h->mode == BatchExecutor::TTSInfo::Mode::search) {
                                if (!h->searchLine) {
                                        h->mode = BatchExecutor::TTSInfo::Mode::found;
                                } else {
-                                       std::smatch result;
-                                       if (std::regex_search(txt, result, ttsMainRegex)) {
-                                               auto sub = result[1].str();
-                                               if (std::regex_search(sub, *h->searchLine))
-                                                       h->mode = BatchExecutor::TTSInfo::Mode::found;
+                                       if (txt.find("(tts_speak_do)") != std::string::npos) {
+                                               auto z = txt.rfind(", text ");
+                                               if (z != std::string::npos) {
+                                                       z += 7;
+                                                       auto z2 = txt.rfind("))");
+                                                       if (z2 != std::string::npos) {
+                                                               auto sub = txt.substr(z, z2 - z);
+                                                               exec->outputStream() << "TTS: '" << sub << "'\n";
+                                                               if (sub.find(*h->searchLine) != std::string::npos) {
+                                                                       h->mode = BatchExecutor::TTSInfo::Mode::found;
+                                                               }
+                                                       }
+                                               }
                                        }
                                }
                        }
index fdbde89..7e8c11c 100644 (file)
@@ -65,7 +65,7 @@ public:
                std::string rootName;
        };
        struct TTSInfo {
-               Optional<std::regex> searchLine;
+               Optional<std::string> searchLine;
                enum class Mode { ignore, search, found };
                Mode mode;
        };
index eaa3fdb..962ff98 100644 (file)
@@ -112,6 +112,7 @@ bool Dlog::start()
                                                auto first = 0;
                                                for (; pos < finalPos; ++pos) {
                                                        if (tmp[pos] == '\n') {
+                                                               line.clear();
                                                                line.replace(0, line.size(), tmp.data() + first, pos - first);
                                                                ASSERT(line.size() == pos - first);
                                                                for (auto &f : h->listeners)