Exemplo n.º 1
0
 public function run(array $context = [])
 {
     if ($this->adb->keyInput(Manager::readConfig($context, self::CFG_EVENT_CODE, $this->eventCode))) {
         return Manager::RET_LOOP;
     }
     return $this->errorReturnCode;
 }
Exemplo n.º 2
0
 public function run(array $context = [])
 {
     $this->adb->connect();
     if (stripos($this->adb->shell->output, 'connected') !== false) {
         $this->adb->exec('devices');
         if (strpos($this->adb->shell->output, "{$this->adb->host}\tdevice") !== false) {
             $this->logger->notice('adb connection established successfully.');
             return Manager::RET_LOOP;
         } else {
             $this->failure('devices');
         }
     } else {
         $this->failure('connect');
     }
 }
Exemplo n.º 3
0
 public function swipe(array $rectangle)
 {
     $this->scr->translateRect($rectangle);
     $retry = 0;
     while (!$this->adb->swipeLine($rectangle)) {
         if (++$retry > $this->retryLimit) {
             $this->logger->error('Abandon retry for tapping screen.');
             return $this->adb->shell->returnCode;
         } else {
             $this->logger->warning('Retry %u for tapping screen.', [$retry]);
         }
         $this->delay->delayOffset($this->retryDelay, $this->retryOffset);
     }
     return true;
 }
Exemplo n.º 4
0
 public function capture($name = '', $orientation = self::AUTO)
 {
     $filename = date('Ymd-His') . '-' . preg_replace('/[^0-9a-z]+/i', '_', $name) . ".png";
     if ($this->adb->screenshot($this->savePath . $filename)) {
         $this->gd = imagecreatefromstring($this->adb->shell->output);
         $this->init($orientation);
         return $this;
     } else {
         throw new \RuntimeException('Capture failed.');
     }
 }
Exemplo n.º 5
0
 public function stopApp()
 {
     $this->adb->stopActivity($this->package);
 }