motion-accessibility 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6beccc1c387aea19480c7388b012b3ad3412288d
4
- data.tar.gz: 63fb9668c4ec729c35ff3b288b9c7206e03aaec5
3
+ metadata.gz: 2e64727e1de692d10abb796a40266e58a754ecfc
4
+ data.tar.gz: 08d0987f4677c22bbb4dd790cc6d76dfea53cdfa
5
5
  SHA512:
6
- metadata.gz: 749913c2a09f2358dea393e9a8bcde203d65277c5eb3c095ed8bfae229cf01239ecfb95d4ab54c2e4b3167a9348dba8725613dab75493314f4ec96abee195356
7
- data.tar.gz: 6d57fc1b39a990a87489f1aec32bd020a27f45dff67d95ce27c3bafc9ef2aac178ce342bfd903e78ae74ed3da83a677d1f4496d8a5bcf0d65ab3030abfba2afb
6
+ metadata.gz: 30b3227b842bb63e39ef1aa1cb937c90075b76cf454c155e241d420c020d3b726e943ae46a7b42962f3af78833c06f8e84d2ee67b10323594fd3faad061496be
7
+ data.tar.gz: c69492392cf2101a301a2cb360b9d7f18d29ab14ca32796f65e884b5275d3e7116d0254d89a4652de513ad8e898b6a4bafd8be716690e1b2223735759a5318cb
@@ -3,6 +3,7 @@
3
3
  module Accessibility
4
4
 
5
5
  def self.inspect(obj)
6
+ return self.inspect(obj.get) if obj.is_a?(RubyMotionQuery::RMQ)
6
7
  displayed=[]
7
8
  if obj.class==Accessibility::Element
8
9
  attributes=A11y::Element_Attributes.dup
@@ -56,10 +57,10 @@ end
56
57
  end
57
58
 
58
59
  def self.inspect_accessibility_traits(obj)
59
- return obj.accessibility_traits if obj.accessibility_traits>Accessibility::Traits.values.max
60
+ return obj.accessibilityTraits if obj.accessibilityTraits>Accessibility::Traits.values.max
60
61
  traits=[]
61
62
  Accessibility::Traits.each do |trait, bitmask|
62
- if obj.accessibility_traits&bitmask>0
63
+ if obj.accessibilityTraits&bitmask>0
63
64
  name=trait.gsub(/_/,' ').capitalize
64
65
  traits<<name
65
66
  end
data/lib/project/test.rb CHANGED
@@ -80,7 +80,7 @@ quiet: false,
80
80
  },
81
81
  UINavigationBar: {
82
82
  accessibility_label: nil,
83
- accessibility_traits: ->(t){A11y::Test.nonstandard(t)},
83
+ accessibility_traits: :nonstandard,
84
84
  accessibility_elements_hidden: false,
85
85
  should_group_accessibility_children: true,
86
86
  accessibility_identifier: [String, "You must set the accessibility_identifier to the title of the view. You can set the title of the view controller or of the navigation item."],
@@ -151,12 +151,12 @@ quiet: false,
151
151
  },
152
152
  UISwitch: {
153
153
  accessibility_label: nil,
154
- accessibility_traits: ->(t){A11y::Test.nonstandard(t, custom: UIAccessibilityTraitButton, message: "You can use :button.")},
154
+ accessibility_traits: :nonstandard,
155
155
  accessibility_value: [String, "You must set the accessibility_value to \"1\" or \"0\""]
156
156
  },
157
157
  UITabBar: {
158
158
  accessibility_label: nil,
159
- accessibility_traits: ->(t){A11y::Test.nonstandard(t)},
159
+ accessibility_traits: :nonstandard,
160
160
  should_group_accessibility_children: true,
161
161
  is_accessibility_element: false,
162
162
  options: {
@@ -166,7 +166,7 @@ quiet: false,
166
166
  },
167
167
  UITabBarButton: {
168
168
  accessibility_label: [String, "You must set the title of this button. You can se tthe title of the UITabBarItem."],
169
- accessibility_traits: ->(t){A11y::Test.nonstandard(t, apple: Bignum, custom: UIAccessibilityTraitButton, message: "You can use :button.")},
169
+ accessibility_traits: :nonstandard,
170
170
  },
171
171
  UITabBarController: {
172
172
  accessibility_label: nil,
@@ -177,10 +177,10 @@ quiet: false,
177
177
  }
178
178
  },
179
179
  UITableView: {
180
- accessibility_label: [String, "You must set the accessibility_label to the default contents of the table view, for example \"Empty List\""],
181
- accessibility_traits: ->(t){A11y::Test.nonstandard(t)},
180
+ accessibility_label: ->(t){table_label(t)},
181
+ accessibility_traits: :nonstandard,
182
182
  should_group_accessibility_children: true,
183
- is_accessibility_element: false
183
+ is_accessibility_element: ->(t){ table_is_element(t)}
184
184
  },
185
185
  UITableViewCell: {
186
186
  accessibility_label: :ignore,
@@ -200,7 +200,7 @@ quiet: false,
200
200
  },
201
201
  UITableTextAccessibilityElement: {
202
202
  accessibility_label: [String, "Set the accessibility_label to the text of the view."],
203
- accessibility_traits: UIAccessibilityTraitStaticText,
203
+ accessibility_traits: :ignore,
204
204
  accessibility_value: String,
205
205
  },
206
206
  UITableViewHeaderFooterView: {
@@ -208,19 +208,19 @@ quiet: false,
208
208
  },
209
209
  UITextField: {
210
210
  accessibility_label: nil,
211
- accessibility_traits: ->(t){A11y::Test.nonstandard(t, apple: Fixnum)},
211
+ accessibility_traits: :nonstandard,
212
212
  accessibility_value: [:something, "You must set the text of the textfield."],
213
213
  is_accessibility_element: false
214
214
  },
215
215
  UIAccessibilityTextFieldElement: {
216
216
  accessibility_label: nil,
217
- accessibility_traits: ->(t){A11y::Test.nonstandard(t, apple: Fixnum)},
217
+ accessibility_traits: :nonstandard,
218
218
  accessibility_value: [:something, "You must set the text of the textfield."],
219
219
  is_accessibility_element: true
220
220
  },
221
221
  UIToolbar: {
222
222
  accessibility_label: nil,
223
- accessibility_traits: ->(t){A11y::Test.nonstandard(t)},
223
+ accessibility_traits: :nonstandard,
224
224
  should_group_accessibility_children: true,
225
225
  is_accessibility_element:false,
226
226
  options: {
@@ -260,6 +260,13 @@ quiet: false,
260
260
  options: {
261
261
  test: :window
262
262
  }
263
+ },
264
+ :"RubyMotionQuery::App" => {
265
+ accessibility_label: nil,
266
+ is_accessibility_element: false,
267
+ options: {
268
+ test: :rmq_app
269
+ }
263
270
  }
264
271
  }
265
272
 
@@ -288,16 +295,17 @@ if UIDevice.currentDevice.systemVersion.to_f>=8.0
288
295
  options: {recurse: false}
289
296
  }
290
297
  Tests[:UITableView] = {
291
- accessibility_label: nil,
292
- accessibility_traits: ->(t){A11y::Test.nonstandard(t)},
298
+ accessibility_label: ->(t){table_label(t)},
299
+ accessibility_traits: :nonstandard,
293
300
  should_group_accessibility_children: true,
294
- is_accessibility_element: false
301
+ is_accessibility_element: ->(t){table_is_element(t)}
295
302
  }
296
303
  Tests[:UITableViewCell] = {
297
304
  accessibility_label: :ignore,
298
305
  accessibility_value: :ignore,
299
306
  should_group_accessibility_children: true,
300
307
  is_accessibility_element: false,
308
+ accessibility_elements_hidden: :ignore,
301
309
  options: {
302
310
  recurse: false,
303
311
  test: :tableViewCell
@@ -372,6 +380,36 @@ controller.viewControllers.each {|c| result=result&&self.run_tests(c)}
372
380
  result
373
381
  end
374
382
 
383
+ def self.table_is_element(table)
384
+ if table.empty?
385
+ unless table.accessibility_element?
386
+ A11y::Test::Log.add(Path, "You must set is_accessibility_element to true for an empty table.")
387
+ return false
388
+ end
389
+ else
390
+ if table.accessibility_element?
391
+ A11y::Test::Log.add(Path, "You must set is_accessibility_element to false for a table with data.")
392
+ return false
393
+ end
394
+ end
395
+ true
396
+ end
397
+
398
+ def self.table_label(table)
399
+ if table.empty?
400
+ unless table.accessibility_label.is_a?(String)
401
+ A11y::Test::Log.add(Path, "You must set the accessibility label to what you want VoiceOver to say instead of an empty table.")
402
+ return false
403
+ end
404
+ else
405
+ unless table.accessibility_label.nil?
406
+ A11y::Test::Log.add(Path, "You must set the accessibility label to nil.")
407
+ return false
408
+ end
409
+ end
410
+ true
411
+ end
412
+
375
413
  def self.tableViewCell(cell)
376
414
  return true if cell.accessibility_label||cell.textLabel.text
377
415
  A11y::Test::Log.add(Path, "Please set the accessibility_label of the UITableViewCell. You can do this by setting the textLabel.text property.")
@@ -386,8 +424,13 @@ result
386
424
  self.run_tests(window.rootViewController)
387
425
  end
388
426
 
427
+ def self.rmq_app(app)
428
+ self.run_tests(app.window)
429
+ end
430
+
389
431
  def self.find_tests(obj)
390
432
  return Tests[obj] if obj.kind_of?(Symbol)
433
+ return Tests[obj.to_s.to_sym] if obj.is_a?(Class)
391
434
  obj_tests=A11y::Test::Tests[:NSObject].clone
392
435
  cl=obj.class
393
436
  class_name=cl.to_s.to_sym
@@ -412,6 +455,7 @@ obj_tests
412
455
  return true if expected==:ignore
413
456
  value=obj.send(attribute) if obj.respond_to?(attribute)
414
457
  return value if expected==:something
458
+ return nonstandard(value) if expected==:nonstandard
415
459
  result=true
416
460
  if expected.class==Class
417
461
  if value.class!=expected
@@ -419,10 +463,9 @@ if value.class!=expected
419
463
  message||="#{attribute} must have an object of type #{expected} instead of #{value}"
420
464
  end
421
465
  elsif expected.kind_of?(Proc)
422
- r=expected.call(value)
466
+ r=expected.call(obj)
423
467
  unless r
424
468
  result=false
425
- message||="The test function for #{attribute} failed."
426
469
  end
427
470
  else
428
471
  unless expected==value
@@ -430,13 +473,14 @@ result=false
430
473
  message||="#{attribute} must have the value \"#{expected}\" instead of \"#{value}\""
431
474
  end
432
475
  end
433
- A11y::Test::Log.add(Path, message) unless result
476
+ A11y::Test::Log.add(Path, message) if message&&!result
434
477
  puts "Testing #{attribute}... #{result}" if Data[:debug]
435
478
  result
436
479
  end
437
480
 
438
481
  def self.run_tests(obj)
439
482
  puts "Entering run_tests: #{obj.inspect}" if Data[:debug]
483
+ return self.run_tests(obj.get) if defined?(RubyMotionQuery::RMQ)&&obj.is_a?(RubyMotionQuery::RMQ)
440
484
  if Data[:depth]==0
441
485
  A11y::Test::Log::Events.clear
442
486
  Path.clear
@@ -510,3 +554,15 @@ result
510
554
 
511
555
  end
512
556
 
557
+ class UITableView
558
+
559
+ def empty?
560
+ cells=0
561
+ numberOfSections.times do |section|
562
+ cells+=numberOfRowsInSection(section)
563
+ end
564
+ cells==0
565
+ end
566
+
567
+ end
568
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-accessibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Seraphin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake