How to use open_minitouch_stream method in ATX

Best Python code snippet using ATX

mixins.py

Source: mixins.py Github

copy

Full Screen

...194 __minitouch_process = None195 def __install_minitouch(self):196 # install minicap & minitouch197 os.system('python -m atx minicap')198 def open_minitouch_stream(self, port=1111):199 if self.__touch_queue is None:200 self.__touch_queue = Queue.Queue()201 # ensure minicap installed202 out = self.raw_cmd('shell', 'ls', '"/​data/​local/​tmp/​minitouch"', stdout=subprocess.PIPE).communicate()[0]203 if 'No such file or directory' in out:204 self.__install_minitouch()205 if self.__minitouch_process is not None:206 self.__minitouch_process.kill()207 out = self.raw_cmd('shell', 'ps', '-C', '/​data/​local/​tmp/​minitouch', stdout=subprocess.PIPE).communicate()[0]208 out = out.strip().split('\n')209 if len(out) > 1:210 p = None211 else:212 p = self.raw_cmd('shell', '/​data/​local/​tmp/​minitouch')213 time.sleep(1)214 if p.poll() is not None:215 # print 'start minitouch failed.'216 return217 self.__minitouch_process = p218 self.raw_cmd('forward', 'tcp:%s' % port, 'localabstract:minitouch').wait()219 def send():220 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)221 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)222 try:223 s.connect(('127.0.0.1', port))224 while True:225 cmd = self.__touch_queue.get() # wait here226 if not cmd:227 continue228 elif cmd[-1] != '\n':229 cmd += '\n'230 s.send(cmd)231 except:232 traceback.print_exc()233 finally:234 s.close()235 self.raw_cmd('forward', '--remove', 'tcp:%s' % port).wait()236 t = threading.Thread(target=send)237 t.setDaemon(True)238 t.start()239 def click(self, x, y):240 cmd = 'd 0 %d %d 30\nc\nu 0\nc\n' % (int(x), int(y))241 self.__touch_queue.put(cmd)242 def swipe(self, sx, sy, ex, ey, steps=20):243 x1, y1, x2, y2 = map(int, (sx, sy, ex, ey))244 dx = (x2 - x1) /​ steps245 dy = (y2 - y1) /​ steps246 send = self.touchqueue.put247 send('d 0 %d %d 30\nc\n' % (x1, y1))248 for i in range(steps - 1):249 x, y = x1 + (i + 1) * dx, y1 + (i + 1) * dy250 send('m 0 %d %d 30\nc\n' % (x, y))251 send('u 0 %d %d 30\nc\nu 0\nc\n' % (x2, y2))252 def pinchin(self, x1, y1, x2, y2, steps=10):253 pass254 def pinchout(self, x1, y1, x2, y2, steps=10):255 pass256class OpenSTFServiceMixin(object):257 pass258# -------------- examples ----------------#259class DummyDevice(object):260 def raw_cmd(self, *args, **kwargs):261 cmds = ['adb'] + list(args)262 # print cmds263 return subprocess.Popen(cmds, **kwargs)264# Mixins should come in front to override functions in Base265class TestDevice(MinitouchStreamMixin, MinicapStreamMixin, RotationWatcherMixin, DummyDevice):266 def __init__(self, *args, **kwargs):267 super(self.__class__, self).__init__(*args, **kwargs)268 self.open_rotation_watcher(on_rotation_change=lambda v: self.open_minicap_stream())269 self.open_minitouch_stream()270if __name__ == '__main__':271 import cv2272 dev = TestDevice()273 while True:274 img = dev.screenshot_cv2()275 if img is not None:276 cv2.imshow('screen', img)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Putting Together a Testing Team

As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

What is Selenium Grid & Advantages of Selenium Grid

Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful