Index: client/site_tests/factory_Review/factory_Review.py |
diff --git a/client/site_tests/factory_Review/factory_Review.py b/client/site_tests/factory_Review/factory_Review.py |
index 13704856f97b669e2a5322f79395be30ac7c80c5..29f10480e6ca7c183e8c6aae000c50728f541fb4 100644 |
--- a/client/site_tests/factory_Review/factory_Review.py |
+++ b/client/site_tests/factory_Review/factory_Review.py |
@@ -18,58 +18,132 @@ import pango |
import sys |
from gtk import gdk |
+from itertools import count, izip, product |
from autotest_lib.client.bin import factory |
from autotest_lib.client.bin import factory_ui_lib as ful |
from autotest_lib.client.bin import test |
from autotest_lib.client.common_lib import error |
+from factory import AutomatedSequence |
+ |
+N_ROW = 15 |
+LABEL_EN_SIZE = (170, 35) |
+LABEL_EN_SIZE_2 = (450, 25) |
+LABEL_EN_FONT = pango.FontDescription('courier new extra-condensed 16') |
+TAB_BORDER = 20 |
+ |
+def trim(text, length): |
+ if len(text) > length: |
+ text = text[:length-3] + '...' |
+ return text |
class factory_Review(test.test): |
version = 1 |
- def run_once(self, |
- status_file_path=None, |
- test_list=None): |
+ def make_summary_tab(self, status_map, tests): |
+ n_test = len(tests) |
+ N_COL = n_test / N_ROW + (n_test % N_ROW != 0) |
+ |
+ info_box = gtk.HBox() |
+ info_box.set_spacing(20) |
+ for status in (ful.ACTIVE, ful.PASSED, ful.FAILED, ful.UNTESTED): |
+ label = ful.make_label(status, |
+ size=LABEL_EN_SIZE, |
+ font=LABEL_EN_FONT, |
+ alignment=(0.5, 0.5), |
+ fg=ful.LABEL_COLORS[status]) |
+ info_box.pack_start(label, False, False) |
+ |
+ status_table = gtk.Table(N_ROW, N_COL, True) |
+ for (j, i), (t, p) in izip(product(xrange(N_COL), xrange(N_ROW)), |
+ tests): |
+ msg_en = t.label_en |
+ if p is not None: |
+ msg_en = ' ' + msg_en |
+ msg_en = trim(msg_en, 12) |
+ if t.label_zw: |
+ msg = '{0:<12} ({1})'.format(msg_en, t.label_zw) |
+ else: |
+ msg = msg_en |
+ status = status_map.lookup_status(t) |
+ status_label = ful.make_label(msg, |
+ size=LABEL_EN_SIZE_2, |
+ font=LABEL_EN_FONT, |
+ alignment=(0.0, 0.5), |
+ fg=ful.LABEL_COLORS[status]) |
+ status_table.attach(status_label, j, j+1, i, i+1) |
+ |
+ vbox = gtk.VBox() |
+ vbox.set_spacing(20) |
+ vbox.pack_start(info_box, False, False) |
+ vbox.pack_start(status_table, False, False) |
+ return vbox |
+ |
+ def make_error_tab(self, status_map, t): |
+ msg = '%s (%s)\n%s' % (t.label_en, t.label_zw, |
+ status_map.lookup_error_msg(t)) |
+ label = ful.make_label(msg, |
+ font=LABEL_EN_FONT, |
+ alignment=(0.0, 0.0)) |
+ label.set_line_wrap(True) |
+ frame = gtk.Frame() |
+ frame.add(label) |
+ return frame |
+ |
+ def key_release_callback(self, widget, event): |
+ factory.log('key_release_callback %s(%s)' % |
+ (event.keyval, gdk.keyval_name(event.keyval))) |
+ if event.keyval == ord('k'): |
+ self.notebook.prev_page() |
+ elif event.keyval == ord('j'): |
+ self.notebook.next_page() |
+ return True |
+ |
+ def register_callback(self, window): |
+ window.connect('key-release-event', self.key_release_callback) |
+ window.add_events(gdk.KEY_RELEASE_MASK) |
+ |
+ def run_once(self, status_file_path=None, test_list=None): |
factory.log('%s run_once' % self.__class__) |
status_map = factory.StatusMap(test_list, status_file_path) |
- untested = status_map.filter(ful.UNTESTED) |
- passed = status_map.filter(ful.PASSED) |
- failed = status_map.filter(ful.FAILED) |
- |
- top_label = ful.make_label('UNTESTED=%d\t' % len(untested) + |
- 'PASSED=%d\t' % len(passed) + |
- 'FAILED=%d' % len(failed)) |
- |
- # decompose automated sequence tests |
- failure_report_list =[] |
- for t in failed: |
- t_name = t.label_en |
- if not isinstance(t, factory.AutomatedSequence): |
- # Simple Test |
- err_msg = status_map.lookup_error_msg(t) |
- failure_report_list.append('%s: %s' % (t_name, err_msg)) |
- continue |
- # Complex Test |
- for subtest in t.subtest_list: |
- if status_map.lookup_status(subtest) != ful.FAILED: |
- continue |
- err_msg = status_map.lookup_error_msg(subtest) |
- failure_report_list.append( |
- '%s: (%s) %s' % (t_name, subtest.label_en, err_msg)) |
- failure_report = ful.make_label('\n'.join(failure_report_list)) |
+ tests = sum(([(t, None)] + |
+ list(product(getattr(t, 'subtest_list', []), [t])) |
+ for t in test_list), []) |
+ |
+ self.notebook = gtk.Notebook() |
+ self.notebook.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
+ |
+ tab = self.make_summary_tab(status_map, tests) |
+ tab.set_border_width(TAB_BORDER) |
+ self.notebook.append_page(tab, ful.make_label('Summary')) |
+ |
+ ts = (t for t, _ in tests |
+ if not isinstance(t, AutomatedSequence) and \ |
+ status_map.lookup_status(t) == ful.FAILED) |
+ for i, t in izip(count(1), ts): |
+ if not isinstance(t, AutomatedSequence) and \ |
+ status_map.lookup_status(t) == ful.FAILED: |
+ tab = self.make_error_tab(status_map, t) |
+ tab.set_border_width(TAB_BORDER) |
+ self.notebook.append_page(tab, ful.make_label('#%02d' % i)) |
+ |
+ control_label = ful.make_label('Press j/k to change tabs', |
+ font=LABEL_EN_FONT, |
+ alignment=(0.5, 0.5)) |
vbox = gtk.VBox() |
vbox.set_spacing(20) |
- vbox.pack_start(top_label, False, False) |
- vbox.pack_start(failure_report, False, False) |
+ vbox.pack_start(control_label, False, False) |
+ vbox.pack_start(self.notebook, False, False) |
test_widget = gtk.EventBox() |
test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
test_widget.add(vbox) |
- ful.run_test_widget(self.job, test_widget) |
+ ful.run_test_widget(self.job, test_widget, |
+ window_registration_callback=self.register_callback) |
factory.log('%s run_once finished' % self.__class__) |