OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // The load should still be alive, but a timer should be started to cancel t
he load inside removeClient(). | 147 // The load should still be alive, but a timer should be started to cancel t
he load inside removeClient(). |
148 cachedImage->removeClient(&client); | 148 cachedImage->removeClient(&client); |
149 EXPECT_EQ(Resource::Pending, cachedImage->status()); | 149 EXPECT_EQ(Resource::Pending, cachedImage->status()); |
150 EXPECT_NE(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(test
URL)); | 150 EXPECT_NE(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(test
URL)); |
151 | 151 |
152 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. | 152 // Trigger the cancel timer, ensure the load was cancelled and the resource
was evicted from the cache. |
153 blink::testing::runPendingTasks(); | 153 blink::testing::runPendingTasks(); |
154 EXPECT_EQ(Resource::LoadError, cachedImage->status()); | 154 EXPECT_EQ(Resource::LoadError, cachedImage->status()); |
155 EXPECT_EQ(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(test
URL)); | 155 EXPECT_EQ(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(test
URL)); |
156 | 156 |
157 blink::Platform::current()->unitTestSupport()->unregisterMockedURL(testURL); | 157 Platform::current()->unitTestSupport()->unregisterMockedURL(testURL); |
158 } | 158 } |
159 | 159 |
160 TEST(ImageResourceTest, DecodedDataRemainsWhileHasClients) | 160 TEST(ImageResourceTest, DecodedDataRemainsWhileHasClients) |
161 { | 161 { |
162 ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest()
); | 162 ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest()
); |
163 cachedImage->setLoading(true); | 163 cachedImage->setLoading(true); |
164 | 164 |
165 MockImageResourceClient client; | 165 MockImageResourceClient client; |
166 cachedImage->addClient(&client); | 166 cachedImage->addClient(&client); |
167 | 167 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ASSERT_FALSE(cachedImage->image()->isNull()); | 211 ASSERT_FALSE(cachedImage->image()->isNull()); |
212 ASSERT_EQ(client.imageChangedCount(), 1); | 212 ASSERT_EQ(client.imageChangedCount(), 1); |
213 ASSERT_TRUE(client.notifyFinishedCalled()); | 213 ASSERT_TRUE(client.notifyFinishedCalled()); |
214 | 214 |
215 HashSet<ImageResource*> bitmapImages; | 215 HashSet<ImageResource*> bitmapImages; |
216 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); | 216 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); |
217 bitmapImages.add(cachedImage.get()); | 217 bitmapImages.add(cachedImage.get()); |
218 } | 218 } |
219 | 219 |
220 } // namespace | 220 } // namespace |
OLD | NEW |