lib/headdesk/checks/teak/api21_icon.rb in headdesk-0.8.0 vs lib/headdesk/checks/teak/api21_icon.rb in headdesk-0.9.0
- old
+ new
@@ -1,7 +1,9 @@
# frozen_string_literal: true
+require 'oily_png'
+
module Headdesk
module Checks
module Teak
#
# Check to make sure that an APK, which uses Teak, has an API 21+ icon.
@@ -22,13 +24,24 @@
.values(v: 21)
.drawable.io_teak_small_notification_icon
export icon: icon, icon_v21: icon_v21
describe "APK contains a drawable for 'io_teak_small_notification_icon'"
- fail_check unless: -> { icon && icon_v21 }
+ fail_check if: -> { icon.nil? || icon_v21.nil? }
describe "'io_teak_small_notification_icon' for v21 is different from < v21"
fail_check unless: -> { icon != icon_v21 }
+
+ resolutions = [['drawable-mdpi', 24], ['drawable-hdpi', 36], ['drawable-xhdpi', 48],
+ ['drawable-xxhdpi', 72], ['drawable-xxxhdpi', 96]]
+ resolutions.each do |rname, size|
+ resource_file = icon_v21.sub('@drawable', "res/#{rname}") + '.png'
+ fail_check unless: -> { apk.resources.file?(resource_file) }
+
+ describe "'#{resource_file}' is #{size}x#{size}"
+ image = ChunkyPNG::Image.from_file(apk.resources.path_for(resource_file))
+ fail_check unless: -> { size == image.width && size == image.height }
+ end
end
end
end
end
end