GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit fed6ce1d authored by boklm's avatar boklm
Browse files

Convert the screenshots test to marionette

parent dbd9fb6f
......@@ -229,7 +229,7 @@ our @tests = (
},
{
name => 'screenshots',
type => 'mozmill',
type => 'marionette',
descr => 'Take some screenshots',
},
{
......@@ -738,6 +738,9 @@ sub marionette_run {
$ENV{PYTHONPATH} = winpath("$FindBin::Bin/marionette/tor_browser_tests/lib");
my $sep = $OSNAME eq 'cygwin' ? ';' : ':';
$ENV{PYTHONPATH} .= $sep . $old_pypath if $old_pypath;
$test->{screenshots} = [];
my $screenshots_tmp = File::Temp::newdir('XXXXXX', DIR => $options->{tmpdir});
$ENV{'MARIONETTE_SCREENSHOTS'} = winpath($screenshots_tmp);
system(xvfb_run($test), "$FindBin::Bin/virtualenv-marionette/$bin/tor-browser-tests",
'--log-unittest', winpath($result_file_txt),
'--log-html', winpath($result_file_html),
......@@ -749,6 +752,13 @@ sub marionette_run {
my $res_line = shift @txt_log;
$test->{results}{success} = $res_line eq ".\n" || $res_line eq ".\r\n";
$test->{results}{log} = join '', @txt_log;
my $i = 0;
for my $screenshot_file (sort glob "$screenshots_tmp/*.png") {
move($screenshot_file, "$tbbinfos->{'results-dir'}/$test->{name}-$i.png");
$screenshot_thumbnail->($tbbinfos->{'results-dir'}, "$test->{name}-$i.png");
push @{$test->{screenshots}}, "$test->{name}-$i.png";
$i++;
}
reset_test_prefs($tbbinfos, $test);
parse_strace($tbbinfos, $test);
check_opened_connections($tbbinfos, $test);
......
......@@ -9,3 +9,18 @@ class TestSuite(object):
with open(tsfile) as json_data:
self.t = json.load(json_data)
def screenshot_filename(self, screenshots_dir):
i = 1
while True:
screenshot_file = "%s/marionette_screenshot-%d.png" % (screenshots_dir, i)
if not os.path.isfile(screenshot_file):
return screenshot_file
i += 1
def screenshot(self, marionette, full=False):
screenshots_dir = os.environ.get('MARIONETTE_SCREENSHOTS')
screenshot_file = self.screenshot_filename(screenshots_dir)
png_data = marionette.screenshot(format='binary', full=full)
output = open(screenshot_file, 'w')
output.write(png_data)
output.close()
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
import testsuite
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
ts = testsuite.TestSuite()
self.ts = ts
self.URLs = [
'chrome://browser/content/preferences/preferences.xul',
'chrome://torbutton/content/preferences.xul',
'chrome://torlauncher/content/network-settings-wizard.xul',
];
def test_check_tpo(self):
marionette = self.marionette
with marionette.using_context('content'):
marionette.navigate("http://check.torproject.org")
self.ts.screenshot(marionette, full=True)
with marionette.using_context('content'):
for url in self.URLs:
marionette.navigate(url)
self.ts.screenshot(marionette)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment