Example #1
0
 def test_get_option_value(self):
     for opt_idx in range(0, self.nb_options):
         desc = rawapi.sane_get_option_descriptor(self.dev_handle, opt_idx)
         if not rawapi.SaneValueType(desc.type).can_getset_opt():
             continue
         val = rawapi.sane_get_option_value(self.dev_handle, opt_idx)
         self.assertNotEqual(val, None)
Example #2
0
 def test_set_option_value(self):
     for opt_idx in range(0, self.nb_options):
         desc = rawapi.sane_get_option_descriptor(self.dev_handle, opt_idx)
         if desc.name != "mode" or not rawapi.SaneValueType(desc.type).can_getset_opt():
             continue
         info = rawapi.sane_set_option_value(self.dev_handle, opt_idx, "Gray")
         self.assertFalse(rawapi.SaneInfo.INEXACT in info)
         val = rawapi.sane_get_option_value(self.dev_handle, opt_idx)
         self.assertEqual(val, "Gray")
Example #3
0
 def test_get_option_descriptor_0(self):
     opt_desc = rawapi.sane_get_option_descriptor(self.dev_handle, 0)
     self.assertEqual(opt_desc.name, "")
     self.assertEqual(opt_desc.title, "Number of options")
     self.assertEqual(opt_desc.type, rawapi.SaneValueType.INT)
     self.assertEqual(opt_desc.unit, rawapi.SaneUnit.NONE)
     self.assertEqual(opt_desc.size, 4)
     self.assertEqual(opt_desc.cap, rawapi.SaneCapabilities.SOFT_DETECT)
     self.assertEqual(opt_desc.constraint_type, rawapi.SaneConstraintType.NONE)
Example #4
0
 def test_get_option_value(self):
     for opt_idx in range(0, self.nb_options):
         desc = rawapi.sane_get_option_descriptor(self.dev_handle, opt_idx)
         if not rawapi.SaneValueType(desc.type).can_getset_opt():
             continue
         if desc.cap | rawapi.SaneCapabilities.INACTIVE == desc.cap:
             continue
         val = rawapi.sane_get_option_value(self.dev_handle, opt_idx)
         self.assertNotEqual(val, None)
Example #5
0
 def test_set_option_value(self):
     for opt_idx in range(0, self.nb_options):
         desc = rawapi.sane_get_option_descriptor(self.dev_handle, opt_idx)
         if (desc.name != "mode"
                 or not rawapi.SaneValueType(desc.type).can_getset_opt()):
             continue
         info = rawapi.sane_set_option_value(self.dev_handle, opt_idx,
                                             "Gray")
         self.assertFalse(rawapi.SaneInfo.INEXACT in info)
         val = rawapi.sane_get_option_value(self.dev_handle, opt_idx)
         self.assertEqual(val, "Gray")
Example #6
0
 def __load_options(self):
     if self.__options != None:
         return
     self._open()
     nb_options = rawapi.sane_get_option_value(sane_dev_handle[1], 0)
     self.__options = {}
     for opt_idx in range(1, nb_options):
         opt_desc = rawapi.sane_get_option_descriptor(sane_dev_handle[1], opt_idx)
         if not rawapi.SaneValueType(opt_desc.type).can_getset_opt():
             continue
         opt = ScannerOption.build_from_rawapi(self, opt_idx, opt_desc)
         self.__options[opt.name] = opt
Example #7
0
 def test_get_option_descriptor_0(self):
     opt_desc = rawapi.sane_get_option_descriptor(self.dev_handle, 0)
     # XXX(Jflesch): The name may vary: sometimes it's empty, sometimes it's
     # "option-cnt"
     #self.assertEqual(opt_desc.name, "")
     self.assertEqual(opt_desc.title, b"Number of options")
     self.assertEqual(opt_desc.type, rawapi.SaneValueType.INT)
     self.assertEqual(opt_desc.unit, rawapi.SaneUnit.NONE)
     self.assertEqual(opt_desc.size, 4)
     self.assertEqual(opt_desc.cap, rawapi.SaneCapabilities.SOFT_DETECT)
     self.assertEqual(opt_desc.constraint_type,
                      rawapi.SaneConstraintType.NONE)
Example #8
0
 def test_get_option_descriptor_0(self):
     opt_desc = rawapi.sane_get_option_descriptor(self.dev_handle, 0)
     # XXX(Jflesch): The name may vary: sometimes it's empty, sometimes it's
     # "option-cnt"
     #self.assertEqual(opt_desc.name, "")
     self.assertEqual(opt_desc.title, b"Number of options")
     self.assertEqual(opt_desc.type, rawapi.SaneValueType.INT)
     self.assertEqual(opt_desc.unit, rawapi.SaneUnit.NONE)
     self.assertEqual(opt_desc.size, 4)
     self.assertEqual(opt_desc.cap, rawapi.SaneCapabilities.SOFT_DETECT)
     self.assertEqual(opt_desc.constraint_type,
                      rawapi.SaneConstraintType.NONE)