Adds middle_point attribute in batch mode 62/164562/43
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Tue, 19 Dec 2017 16:02:39 +0000 (17:02 +0100)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 18 Jan 2018 12:29:38 +0000 (13:29 +0100)
Adds middle_point attribute to atspi object, which returns middle point
of object's current screen position. Information is not cached.

Change-Id: I0d41ce4ef882be1554dadbf77ddbb2f139020caa

src/batch/BatchRunner.cpp

index 657a8fb..0a887e6 100644 (file)
@@ -137,6 +137,23 @@ struct TestExecutor : ExecutorInterface {
                        if (!result) throw EvaluationFailure{} << "failed to get at-spi object's name (use dlogutil to get at-spi error message)";
                        return *result;
                };
+               getters[ { EvaluationValue::Kind::UIELEMENT, "middle_point" }] = [&](const EvaluationValue & self) -> EvaluationValue {
+                       auto uiElem = self.asUiElement();
+                       ASSERT(uiElem->getObject());
+                       Optional<Rectangle> result;
+                       executeOnMainThread([&]()
+                       {
+                               auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
+                               auto comp = atspi->getComponentInterface(uiElem->getObject());
+                               if (comp) {
+                                       auto found = atspi->getScreenPosition(comp);
+                                       if (found)
+                                               result = *found;
+                               }
+                       });
+                       if (!result) throw EvaluationFailure{} << "failed to get at-spi object's screen position (use dlogutil to get at-spi error message)";
+                       return (*result).getCenterPoint();
+               };
                for (auto activityName : ActivityFactory::getInstance()->getAllActivityTypes()) {
                        variables[activityName] = EvaluationValue::FunctionType::Type{
                                [ = ](EvaluationContext & ec, std::vector<EvaluationValue> args) -> EvaluationValue {