Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebImageTest.cpp

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 return testing::ReadFromFile(file_path); 44 return testing::ReadFromFile(file_path);
45 } 45 }
46 46
47 TEST(WebImageTest, PNGImage) { 47 TEST(WebImageTest, PNGImage) {
48 RefPtr<SharedBuffer> data = ReadFile("white-1x1.png"); 48 RefPtr<SharedBuffer> data = ReadFile("white-1x1.png");
49 ASSERT_TRUE(data.Get()); 49 ASSERT_TRUE(data.Get());
50 50
51 WebImage image = WebImage::FromData(WebData(data), WebSize()); 51 WebImage image = WebImage::FromData(WebData(data), WebSize());
52 EXPECT_TRUE(image.Size() == WebSize(1, 1)); 52 EXPECT_TRUE(image.Size() == WebSize(1, 1));
53 SkAutoLockPixels auto_lock(image.GetSkBitmap());
54 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), 53 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255),
55 image.GetSkBitmap().getColor(0, 0)); 54 image.GetSkBitmap().getColor(0, 0));
56 } 55 }
57 56
58 TEST(WebImageTest, ICOImage) { 57 TEST(WebImageTest, ICOImage) {
59 RefPtr<SharedBuffer> data = ReadFile("black-and-white.ico"); 58 RefPtr<SharedBuffer> data = ReadFile("black-and-white.ico");
60 ASSERT_TRUE(data.Get()); 59 ASSERT_TRUE(data.Get());
61 60
62 WebVector<WebImage> images = WebImage::FramesFromData(WebData(data)); 61 WebVector<WebImage> images = WebImage::FramesFromData(WebData(data));
63 ASSERT_EQ(2u, images.size()); 62 ASSERT_EQ(2u, images.size());
64 EXPECT_TRUE(images[0].Size() == WebSize(2, 2)); 63 EXPECT_TRUE(images[0].Size() == WebSize(2, 2));
65 EXPECT_TRUE(images[1].Size() == WebSize(1, 1)); 64 EXPECT_TRUE(images[1].Size() == WebSize(1, 1));
66 SkAutoLockPixels auto_lock1(images[0].GetSkBitmap());
67 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), 65 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255),
68 images[0].GetSkBitmap().getColor(0, 0)); 66 images[0].GetSkBitmap().getColor(0, 0));
69 SkAutoLockPixels auto_lock2(images[1].GetSkBitmap());
70 EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0), 67 EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0),
71 images[1].GetSkBitmap().getColor(0, 0)); 68 images[1].GetSkBitmap().getColor(0, 0));
72 } 69 }
73 70
74 TEST(WebImageTest, ICOValidHeaderMissingBitmap) { 71 TEST(WebImageTest, ICOValidHeaderMissingBitmap) {
75 RefPtr<SharedBuffer> data = ReadFile("valid_header_missing_bitmap.ico"); 72 RefPtr<SharedBuffer> data = ReadFile("valid_header_missing_bitmap.ico");
76 ASSERT_TRUE(data.Get()); 73 ASSERT_TRUE(data.Get());
77 74
78 WebVector<WebImage> images = WebImage::FramesFromData(WebData(data)); 75 WebVector<WebImage> images = WebImage::FramesFromData(WebData(data));
79 ASSERT_TRUE(images.IsEmpty()); 76 ASSERT_TRUE(images.IsEmpty());
80 } 77 }
81 78
82 TEST(WebImageTest, BadImage) { 79 TEST(WebImageTest, BadImage) {
83 const char kBadImage[] = "hello world"; 80 const char kBadImage[] = "hello world";
84 WebVector<WebImage> images = WebImage::FramesFromData(WebData(kBadImage)); 81 WebVector<WebImage> images = WebImage::FramesFromData(WebData(kBadImage));
85 ASSERT_EQ(0u, images.size()); 82 ASSERT_EQ(0u, images.size());
86 83
87 WebImage image = WebImage::FromData(WebData(kBadImage), WebSize()); 84 WebImage image = WebImage::FromData(WebData(kBadImage), WebSize());
88 EXPECT_TRUE(image.GetSkBitmap().empty()); 85 EXPECT_TRUE(image.GetSkBitmap().empty());
89 EXPECT_TRUE(image.GetSkBitmap().isNull()); 86 EXPECT_TRUE(image.GetSkBitmap().isNull());
90 } 87 }
91 88
92 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698