| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 # DESCRIPTION : factory test of ambient light sensor. Test that ALS reacts to | 7 # DESCRIPTION : factory test of ambient light sensor. Test that ALS reacts to |
| 8 # both darkening by covering w/ finger as well as brightening. | 8 # both darkening by covering w/ finger as well as brightening. |
| 9 # Roughly speaking: | 9 # Roughly speaking: |
| 10 # indoor ambient lighting: 20-100 | 10 # indoor ambient lighting: 20-100 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 self.cfg() | 54 self.cfg() |
| 55 | 55 |
| 56 self.ambient = self.read('mean',delay=0,samples=10) | 56 self.ambient = self.read('mean',delay=0,samples=10) |
| 57 factory.log('ambient light sensor = %d' % self.ambient) | 57 factory.log('ambient light sensor = %d' % self.ambient) |
| 58 | 58 |
| 59 def cfg(self): | 59 def cfg(self): |
| 60 cmd = self.PARAMS['init'] | 60 cmd = self.PARAMS['init'] |
| 61 utils.system(cmd) | 61 utils.system(cmd) |
| 62 time.sleep(1) | 62 time.sleep(1) |
| 63 if not os.path.isfile(self.PARAMS['rd']): | 63 if not os.path.isfile(self.PARAMS['rd']): |
| 64 raise error.CmdError(cmd + 'did not create' + self.PARAMS['rd']) | 64 raise error.TestError(cmd + 'did not create ' + self.PARAMS['rd']) |
| 65 val = self.read('first',samples=1) | 65 val = self.read('first',samples=1) |
| 66 if val <= self.PARAMS['min'] or val >= self.PARAMS['max']: | 66 if val <= self.PARAMS['min'] or val >= self.PARAMS['max']: |
| 67 raise error.CmdError("Failed initial read\n") | 67 raise error.TestError("Failed initial read\n") |
| 68 | 68 |
| 69 | 69 |
| 70 def read(self, type, delay=None, samples=1): | 70 def read(self, type, delay=None, samples=1): |
| 71 ''' | 71 ''' |
| 72 Read the light sensor and return value based on type | 72 Read the light sensor and return value based on type |
| 73 @parameter type - string describing type of value to return. Valid | 73 @parameter type - string describing type of value to return. Valid |
| 74 strings are 'mean' | 'min' | 'max' | 'raw' | 74 strings are 'mean' | 'min' | 'max' | 'raw' |
| 75 @parameter delay - delay between samples in seconds. 0 means as fast as | 75 @parameter delay - delay between samples in seconds. 0 means as fast as |
| 76 possible | 76 possible |
| 77 @parameter samples - total samples to read. O means infinite | 77 @parameter samples - total samples to read. O means infinite |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 ful.run_test_widget(self.job, vbox, | 207 ful.run_test_widget(self.job, vbox, |
| 208 window_registration_callback=self.register_callbacks) | 208 window_registration_callback=self.register_callbacks) |
| 209 | 209 |
| 210 failed_set = set(name for name, status in self._status_map.items() | 210 failed_set = set(name for name, status in self._status_map.items() |
| 211 if status is not ful.PASSED) | 211 if status is not ful.PASSED) |
| 212 if failed_set: | 212 if failed_set: |
| 213 raise error.TestFail('some subtests failed (%s)' % | 213 raise error.TestFail('some subtests failed (%s)' % |
| 214 ', '.join(failed_set)) | 214 ', '.join(failed_set)) |
| 215 | 215 |
| 216 factory.log('%s run_once finished' % self.__class__) | 216 factory.log('%s run_once finished' % self.__class__) |
| OLD | NEW |