1# Copyright 2013 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""CameraITS test to see sensitivity param applied properly in burst or not.
15"""
16
17from mobly import test_runner
18
19import its_base_test
20import camera_properties_utils
21import capture_request_utils
22import its_session_utils
23
24NUM_STEPS = 3
25ERROR_TOLERANCE = 0.96  # Allow ISO to be rounded down by 4%
26
27
28class ParamSensitivityBurstTest(its_base_test.ItsBaseTest):
29  """Test android.sensor.sensitivity parameter applied properly in burst.
30
31  Inspects the output metadata only (not the image data).
32  """
33
34  def test_param_sensitivity_burst(self):
35    with its_session_utils.ItsSession(
36        device_id=self.dut.serial,
37        camera_id=self.camera_id,
38        hidden_physical_id=self.hidden_physical_id) as cam:
39      props = cam.get_camera_properties()
40      props = cam.override_with_hidden_physical_camera_props(props)
41      camera_properties_utils.skip_unless(
42          camera_properties_utils.manual_sensor(props) and
43          camera_properties_utils.per_frame_control(props))
44
45      sens_range = props['android.sensor.info.sensitivityRange']
46      sens_step = (sens_range[1] - sens_range[0]) // NUM_STEPS
47      sens_list = range(sens_range[0], sens_range[1], sens_step)
48      exp = min(props['android.sensor.info.exposureTimeRange'])
49      assert exp != 0
50      reqs = [
51          capture_request_utils.manual_capture_request(s, exp)
52          for s in sens_list
53      ]
54      _, fmt = capture_request_utils.get_fastest_manual_capture_settings(props)
55
56      caps = cam.do_capture(reqs, fmt)
57      for i, cap in enumerate(caps):
58        s_req = sens_list[i]
59        s_res = cap['metadata']['android.sensor.sensitivity']
60        msg = 's_write: %d, s_read: %d, TOL: %.2f' % (s_req, s_res,
61                                                      ERROR_TOLERANCE)
62        assert s_req >= s_res, msg
63        assert s_res / float(s_req) > ERROR_TOLERANCE, msg
64
65
66if __name__ == '__main__':
67  test_runner.main()
68