Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2554)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_testserver.py

Issue 10073033: Run safebrowsing_service_test through the net testserver code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix warning Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_testserver.py
diff --git a/chrome/browser/safe_browsing/safe_browsing_testserver.py b/chrome/browser/safe_browsing/safe_browsing_testserver.py
new file mode 100644
index 0000000000000000000000000000000000000000..c11b60ffa7b3ff6414d2171e1d5880e2a658c03f
--- /dev/null
+++ b/chrome/browser/safe_browsing/safe_browsing_testserver.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Wraps the upstream safebrowsing_test_server.py to run in Chrome tests."""
+
+import os
+import sys
+
+sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ '..', '..', '..', 'net',
+ 'tools', 'testserver'))
+import testserver_base
+
+class ServerRunner(testserver_base.TestServerRunner):
+ def create_server(self, server_data):
+ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
+ '..', '..', '..', 'third_party',
+ 'safe_browsing', 'testing'))
+ import safebrowsing_test_server
+ server = safebrowsing_test_server.SetupServer(
+ self.options.data_file, self.options.host, self.options.port,
+ opt_enforce_caching=False, opt_validate_database=True)
+ print 'Safebrowsing HTTP server started on port %d...' % server.server_port
+ server_data['port'] = server.server_port
+
+ return server
+
+ def add_options(self):
+ testserver_base.TestServerRunner.add_options(self)
+ self.option_parser.add_option('', '--data-file', dest='data_file',
+ help='File containing safebrowsing test '
+ 'data and expectations')
+ # TODO(mattm): we define an unnecessary --data-dir option because
+ # BaseTestServer unconditionally sets --data-dir. This should be removed
+ # when BaseTestServer is refactored to not contain all the net/
+ # test_server.py specific stuff.
+ self.option_parser.add_option('', '--data-dir', dest='data_dir',
+ help='unused')
+
+if __name__ == '__main__':
+ sys.exit(ServerRunner().main())

Powered by Google App Engine
This is Rietveld 408576698