STOUT-FACTORY: Specify dir to read keyboard image and bindings from.
BUG=chrome-os-partner:13735
TEST=manual
Change-Id: I48a03343ab15999dff5d11a0921058f42e820678
Original-Change-Id: I16da7244d006065a12d1205b97552e8f4d918718
Reviewed-on: https://gerrit.chromium.org/gerrit/33557
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
diff --git a/client/site_tests/factory_Keyboard/factory_Keyboard.py b/client/site_tests/factory_Keyboard/factory_Keyboard.py
index 7d8eea3..ba6b07d 100644
--- a/client/site_tests/factory_Keyboard/factory_Keyboard.py
+++ b/client/site_tests/factory_Keyboard/factory_Keyboard.py
@@ -238,7 +238,15 @@
return layout
return None
- def run_once(self, layout=None, combi_key=False):
+ def run_once(self, layout=None, combi_key=False, config_dir=''):
+ '''
+
+ Args:
+ layout: use specified layout other than derived from VPD.
+ combi_key: True to handle key combination.
+ config_dir: specify directory to read keyboard image and binding
+ from. If unspeified, read from default directory.
+ '''
factory.log('%s run_once' % self.__class__)
@@ -252,15 +260,17 @@
layout = 'en-US'
factory.log("Using keyboard layout %s" % layout)
+ layout_filename = os.path.join(config_dir, '%s.png' % layout)
try:
- kbd_image = cairo.ImageSurface.create_from_png('%s.png' % layout)
+ kbd_image = cairo.ImageSurface.create_from_png(layout_filename)
image_size = (kbd_image.get_width(), kbd_image.get_height())
except cairo.Error as e:
- raise error.TestNAError('Error while opening %s.png: %s' %
- (layout, e.message))
+ raise error.TestNAError('Error while opening %s: %s' %
+ (layout_filename, e.message))
+ bindings_filename = os.path.join(config_dir, '%s.bindings' % layout)
try:
- with open('%s.bindings' % layout, 'r') as file:
+ with open(bindings_filename, 'r') as file:
bindings = eval(file.read())
bindings = GenerateKeycodeBinding(bindings)
except IOError as e: