Пример #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')

        # "config" only passes the fields under "profilers", so config.json is loaded again for the fields below
        # FIX
        config_f = self.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 = self.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'])
            ]
Пример #2
0
    def __init__(self, config, paths, full_config={}):
        super(Batterystats, self).__init__(config, paths)
        self.output_dir = ''
        self.paths = paths
        self.profile = False
        self.cleanup = config.get('cleanup')

        # Compatibility
        if 'type' not in full_config:
            full_config = load_json(
                op.join(self.paths["CONFIG_DIR"],
                        self.paths['ORIGINAL_CONFIG_DIR']))

        self.type = full_config['type']
        self.systrace = full_config.get('systrace_path', 'systrace')
        self.powerprofile = full_config['powerprofile_path']
        self.duration = self.is_integer(full_config.get('duration', 0)) / 1000
        if self.type == 'web':
            self.browsers = [
                BrowserFactory.get_browser(b)(full_config)
                for b in full_config.get('browsers', ['chrome'])
            ]
Пример #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_firefox(self, browser):
     assert BrowserFactory.get_browser('firefox')(
         None).to_string() == 'org.mozilla.firefox'
Пример #5
0
 def test_browsers_to_string_opera(self, browser):
     assert BrowserFactory.get_browser('opera')(
         None).to_string() == 'com.opera.browser'
Пример #6
0
 def test_get_browser_fake(self):
     with pytest.raises(Exception) as except_result:
         BrowserFactory.get_browser("fake_browser")
     assert "No Browser found" in except_result.value
Пример #7
0
 def test_get_browser_firefox(self):
     assert isinstance(BrowserFactory.get_browser('firefox'),
                       Firefox.Firefox.__class__)
Пример #8
0
 def test_get_browser_opera(self):
     assert isinstance(BrowserFactory.get_browser('opera'),
                       Opera.Opera.__class__)
Пример #9
0
 def test_get_browser_chrome(self):
     assert isinstance(BrowserFactory.get_browser('chrome'),
                       Chrome.Chrome.__class__)