fix for invalid context change notification, when new context has the same name 91/210491/1
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Fri, 19 Jul 2019 14:00:10 +0000 (16:00 +0200)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Fri, 19 Jul 2019 14:00:10 +0000 (16:00 +0200)
Change-Id: I5d4b22fc819ec9091429f83a9c7a3131849ccf17

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

index 2cff47232cc725aa49f6859715f793bf6398d508..48715ba2d4787a2f6be40d4671174082d4a08607 100644 (file)
@@ -227,6 +227,7 @@ void BatchExecutor::registerContextChangeCallback()
                h->root = std::move(root);
                h->keyboardRoot = std::move(keyboardRoot);
                h->rootName = std::move(name);
+               h->rootAddress = h->root ? Atspi::getUniqueId(h->root->getObject()) : "";
        };
        updateContextInfo(nav->getCurrentVisibleRoot(), nav->getCurrentKeyboardVisibleRoot(), nav->getCurrentNavigationContext());
        contextChangedHandle = nav->registerCb<NavigationCallbackType::ContextChanged>(std::move(updateContextInfo));
@@ -1092,21 +1093,21 @@ void BatchExecutor::insertMethods()
        auto generateWheelTurnFunction = [&]() {
                return EvaluationValueFunction{ [&](bool clockwise, int multiplicity) -> EvaluationValue {
 
-                       if (multiplicity <= 0)
-                               throw EvaluationFailure{} << "Invalid multiplicity (must be more that 0)";
+                               if (multiplicity <= 0)
+                                       throw EvaluationFailure{} << "Invalid multiplicity (must be more that 0)";
 
-                       auto delay = multiplicity > 1 ? 0.75 : 0;
+                               auto delay = multiplicity > 1 ? 0.75 : 0;
 
-                       executeOnMainThread([&]()
-                       {
-                               utils::generateWheelTurn(clockwise, multiplicity, delay);
-                       });
+                               executeOnMainThread([&]()
+                               {
+                                       utils::generateWheelTurn(clockwise, multiplicity, delay);
+                               });
 
-                       int await = 1000 * (multiplicity * delay);
-                       std::this_thread::sleep_for(std::chrono::milliseconds{ await });
+                               int await = 1000 * (multiplicity * delay);
+                               std::this_thread::sleep_for(std::chrono::milliseconds{ await });
 
-                       return EvaluationValue{};
-               },  { {"clockwise", true}, {"multiplicity", 1} } };
+                               return EvaluationValue{};
+                       },  { {"clockwise", true}, {"multiplicity", 1} } };
        };
        variables["TURN_WHEEL"] = generateWheelTurnFunction();
 }
@@ -1225,23 +1226,27 @@ public:
        {
                auto h = self->contextInfo.lock();
                this->currentContextName = h->rootName;
+               this->currentContextAddress = h->rootAddress;
        }
 private:
        void prepare() override
        {
                auto h = self->contextInfo.lock();
                currentContextName = h->rootName;
+               currentContextAddress = h->rootAddress;
        }
        void joinImpl() override
        {
                auto h = self->contextInfo.lock();
                auto pred = [&]() {
-                       if (currentContextName != h->rootName) {
-                               self->outputStream() << "context name changed from '" << currentContextName << "', to '" << h->rootName << "'\n";
+                       if (currentContextAddress != h->rootAddress) {
+                               self->outputStream() << "context name changed from " <<
+                                                                        "'" << currentContextName << "' (" << currentContextAddress << "), to " <<
+                                                                        "'" << h->rootName << "' (" << h->rootAddress << "), while looking for '" << name << "'\n";
                                currentContextName = h->rootName;
-                               if (name.empty()) {
+                               currentContextAddress = h->rootAddress;
+                               if (name.empty())
                                        return true;
-                               }
                        }
                        return !name.empty() && name == h->rootName;
                };
@@ -1255,6 +1260,7 @@ private:
        }
 
        std::string name, currentContextName;
+       std::string currentContextAddress;
 };
 
 void BatchExecutor::insertWaits()
index 8c58b463d2cc52f7995fb52617800b95aafd8d44..fa102ce72d8b3b1e18c7c42565336402c8d67e4b 100644 (file)
@@ -67,7 +67,7 @@ public:
                std::shared_ptr<UIElement> root;
                std::shared_ptr<UIElement> keyboardRoot;
                std::shared_ptr<NavigationElement> navigation;
-               std::string rootName;
+               std::string rootName, rootAddress;
        };
        struct TTSInfo {
                struct Entry {