autotest三种主要测试手段
- 直接调用系统命令,相当于直接运行shell命令
- 通过dbus进行method call
- 通过加载插件到browser的方式,运行js代码,以js代码来调用C++方法
通过extension来运行js代码
目的:通过js间接调用C++方法;
实现:
- restart ui、stop browser
- 通过dbus --send method_call来请求session_manager启动一个新的浏览器实例;所使用的浏览器启动参数包含
--load-extension
,指定需要加载的插件,插件包含即将运行的js代码。
在此之前需要杀死所有浏览器实例,否则,由于perference在有浏览器实例存在时不会被更新,因此加入的参数可能会没有作用。
Most of the command-line flags are only effective when all existing instances of Chrome that corresponds to the chrome profile have been terminated.
因此需要在加载插件之前将所有进程名为chrome的进程杀死。
自动测试框图
graph LR
autotest_python-->dbus
dbus-->C++
C++-->CrOS
autotest_python-->extension_Chrome
extension_Chrome-->js
js-->C++
C++-->CrOS
autotest_python-->shell
shell-->CrOS
![在这里插入图片描述](https://img-blog.csdnimg.cn/20181120114145566.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3JlYWxEb25hbGRUcnVtcA==,size_16,color_FFFFFF,t_70)