コード例 #1
0
    def __init__(self, config, paths):
        super(Batterystats, self).__init__(config, paths)
        self.output_dir = ''
        self.paths = paths
        self.profile = False
        self.cleanup = config.get('cleanup')
        self.enable_systrace_parsing = config.get('enable_systrace_parsing',
                                                  True)
        self.python2_path = config.get('python2_path', 'python2')

        # "config" only passes the fields under "profilers", so config.json is loaded again for the fields below
        # FIX
        config_f = util.load_json(
            op.join(self.paths["CONFIG_DIR"],
                    self.paths['ORIGINAL_CONFIG_DIR']))
        self.type = config_f['type']
        self.systrace = config_f.get('systrace_path', 'systrace')
        self.powerprofile = config_f['powerprofile_path']
        self.duration = Tests.is_integer(config_f.get('duration', 0)) / 1000
        if self.type == 'web':
            self.browsers = [
                BrowserFactory.get_browser(b)(config_f)
                for b in config_f.get('browsers', ['chrome'])
            ]

        if os.path.exists(
                self.systrace
        ):  # If it does not exist, then there might be a prefix already added to the path
            self.systrace = ' '.join([self.python2_path, self.systrace])
        else:
            print("Did not prefix python2 path to systrace path due to the systrace path not existing. " + \
                  "This is fine if you added a prefix path yourself, if not, double check the systrace_path inside of your config and make sure it exists.")
コード例 #2
0
 def test_browsers_to_string_firefox(self, browser):
     assert BrowserFactory.get_browser('firefox')(
         None).to_string() == 'org.mozilla.firefox'
コード例 #3
0
 def test_browsers_to_string_chrome(self, browser):
     assert BrowserFactory.get_browser('chrome')(
         None).to_string() == 'com.android.chrome'
コード例 #4
0
 def test_browsers_to_string_opera(self, browser):
     assert BrowserFactory.get_browser('opera')(
         None).to_string() == 'com.opera.browser'
コード例 #5
0
 def test_get_browser_fake(self):
     with pytest.raises(Exception) as except_result:
         BrowserFactory.get_browser("fake_browser")
     assert "No Browser found" in str(except_result.value)
コード例 #6
0
 def test_get_browser_firefox(self):
     assert isinstance(BrowserFactory.get_browser('firefox'),
                       Firefox.Firefox.__class__)
コード例 #7
0
 def test_get_browser_opera(self):
     assert isinstance(BrowserFactory.get_browser('opera'),
                       Opera.Opera.__class__)
コード例 #8
0
 def test_get_browser_chrome(self):
     assert isinstance(BrowserFactory.get_browser('chrome'),
                       Chrome.Chrome.__class__)