Skip to content

Commit

Permalink
Assert that our PNG images are 64x64 px
Browse files Browse the repository at this point in the history
`shipit.png` is 75 px for some reason, though.
  • Loading branch information
mislav committed Jul 4, 2014
1 parent 2b26bb9 commit c5ee5eb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/integrity_test.rb
Expand Up @@ -31,6 +31,21 @@ class IntegrityTest < TestCase
end end
end end


test "images on disk are 64x64" do
mismatches = []
Dir["#{Emoji.images_path}/**/*.png"].each do |image_file|
width, height = png_dimensions(image_file)
unless width == 64 && height == 64
mismatches << "%s: %dx%d" % [
image_file.sub(Emoji.images_path, ''),
width,
height
]
end
end
assert_equal ["/emoji/shipit.png: 75x75"], mismatches
end

test "missing or incorrect unicodes" do test "missing or incorrect unicodes" do
missing = source_unicode_emoji - Emoji.all.map(&:raw).compact missing = source_unicode_emoji - Emoji.all.map(&:raw).compact
assert_equal 0, missing.size, missing_unicodes_message(missing) assert_equal 0, missing.size, missing_unicodes_message(missing)
Expand Down Expand Up @@ -58,4 +73,9 @@ def db
def source_unicode_emoji def source_unicode_emoji
@source_unicode_emoji ||= db["EmojiDataArray"].flat_map { |data| data["CVCategoryData"]["Data"].split(",") } @source_unicode_emoji ||= db["EmojiDataArray"].flat_map { |data| data["CVCategoryData"]["Data"].split(",") }
end end

def png_dimensions(file)
png = File.open(file, "rb") { |f| f.read(1024) }
png.unpack("x16N2")
end
end end

0 comments on commit c5ee5eb

Please sign in to comment.