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

Unified Diff: client/common_lib/factory_test.py

Issue 2836043: Relocate library files for wider access and re-use; also associated cleanup. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: patch typo Created 10 years, 6 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
« no previous file with comments | « client/bin/factory_ui_lib.py ('k') | client/site_tests/factory_Camera/factory_Camera.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/factory_test.py
diff --git a/client/common_lib/factory_test.py b/client/common_lib/factory_test.py
deleted file mode 100644
index e356f01bd29a3905e7524fc687df74f846a00947..0000000000000000000000000000000000000000
--- a/client/common_lib/factory_test.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-# DESCRIPTION :
-#
-# This library provides convenience routines to launch factory tests.
-# This includes support for identifying keyboard test switching
-# triggers, grabbing control of the keyboard and mouse, and making the
-# mouse cursor disappear. It also manages communication of any found
-# keyboard triggers to the control process, via writing data to
-# _result_file_path.
-
-
-from autotest_lib.client.common_lib import error
-
-import gtk
-import sys
-
-
-def XXX_log(s):
- print >> sys.stderr, 'FACTORY: ' + s
-
-
-_BLACK = gtk.gdk.color_parse('black')
-
-
-_got_trigger = None
-_trigger_set = None
-_result_file_path = None
-
-
-def init(trigger_set=set(), result_file_path=None):
- global _trigger_set, _result_file_path
- _result_file_path = result_file_path
- _trigger_set = [ord(x) for x in trigger_set]
-
-
-def test_switch_on_trigger(event):
- char = event.keyval in range(32,127) and chr(event.keyval) or None
- global _trigger_set, _result_file_path, _got_trigger
- if ('GDK_CONTROL_MASK' not in event.state.value_names
- or event.keyval not in _trigger_set):
- return False
- XXX_log('got test switch trigger %s(%s)' % (event.keyval, char))
- _got_trigger = char
- gtk.main_quit()
- return True
-
-
-def run_test_widget(test_widget=None, test_widget_size=None,
- invisible_cursor=True,
- window_registration_callback=None,
- cleanup_callback=None):
-
- window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- window.modify_bg(gtk.STATE_NORMAL, _BLACK)
- window.set_size_request(*test_widget_size)
-
- align = gtk.Alignment(xalign=0.5, yalign=0.5)
- align.add(test_widget)
-
- window.add(align)
- window.show_all()
-
- gtk.gdk.pointer_grab(window.window, confine_to=window.window)
- gtk.gdk.keyboard_grab(window.window)
-
- if invisible_cursor:
- pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
- color = gtk.gdk.Color()
- cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
- window.window.set_cursor(cursor)
-
- if window_registration_callback is not None:
- window_registration_callback(window)
-
- XXX_log('factory_test running gtk.main')
- gtk.main()
- XXX_log('factory_test quit gtk.main')
-
- if cleanup_callback is not None:
- cleanup_callback()
-
- gtk.gdk.pointer_ungrab()
- gtk.gdk.keyboard_ungrab()
-
- global _got_trigger
- if _got_trigger is None:
- return
- with open(_result_file_path, 'w') as file:
- file.write('%s\n' % repr(_got_trigger))
- raise error.TestFail('explicit test switch triggered (%s)' % _got_trigger)
« no previous file with comments | « client/bin/factory_ui_lib.py ('k') | client/site_tests/factory_Camera/factory_Camera.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698