Home | History | Annotate | Download | only in tests
      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 
     15 import its.image
     16 import its.device
     17 import its.objects
     18 import pylab
     19 import os.path
     20 import matplotlib
     21 import matplotlib.pyplot
     22 
     23 def main():
     24     """Test that the android.flash.mode parameter is applied.
     25     """
     26     NAME = os.path.basename(__file__).split(".")[0]
     27 
     28     req = its.objects.auto_capture_request()
     29 
     30     flash_modes_reported = []
     31     flash_states_reported = []
     32 
     33     with its.device.ItsSession() as cam:
     34         for f in [0,1,2]:
     35             req["captureRequest"]["android.flash.mode"] = f
     36             fname, w, h, cap_md = cam.do_capture(req)
     37             flash_modes_reported.append(
     38                     cap_md["captureResult"]["android.flash.mode"])
     39             flash_states_reported.append(
     40                     cap_md["captureResult"]["android.flash.state"])
     41             img = its.image.load_yuv420_to_rgb_image(fname, w, h)
     42             its.image.write_image(img, "%s_mode=%d.jpg" % (NAME, f))
     43 
     44     assert(flash_modes_reported == [0,1,2])
     45 
     46     # TODO: Add check on flash_states_reported values.
     47 
     48     # TODO: Add an image check on the brightness of the captured shots, as well
     49     # as the exposure values in the capture result, to test that flash was
     50     # fired as expected (i.e.) on the shots it was expected to be fired for.
     51 
     52 if __name__ == '__main__':
     53     main()
     54 
     55