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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 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 27 matching lines...) Expand all
38 #include "platform/SharedBuffer.h" 38 #include "platform/SharedBuffer.h"
39 #include "platform/exported/WrappedResourceResponse.h" 39 #include "platform/exported/WrappedResourceResponse.h"
40 #include "platform/graphics/Image.h" 40 #include "platform/graphics/Image.h"
41 #include "platform/testing/URLTestHelpers.h" 41 #include "platform/testing/URLTestHelpers.h"
42 #include "platform/testing/UnitTestHelpers.h" 42 #include "platform/testing/UnitTestHelpers.h"
43 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
44 #include "public/platform/WebURL.h" 44 #include "public/platform/WebURL.h"
45 #include "public/platform/WebURLLoaderMockFactory.h" 45 #include "public/platform/WebURLLoaderMockFactory.h"
46 #include "public/platform/WebURLResponse.h" 46 #include "public/platform/WebURLResponse.h"
47 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
48 #include "wtf/PtrUtil.h"
49 #include <memory>
48 50
49 namespace blink { 51 namespace blink {
50 52
51 static Vector<unsigned char> jpegImage() 53 static Vector<unsigned char> jpegImage()
52 { 54 {
53 Vector<unsigned char> jpeg; 55 Vector<unsigned char> jpeg;
54 56
55 static const unsigned char data[] = { 57 static const unsigned char data[] = {
56 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 58 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00,
57 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 59 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 103
102 virtual ~ImageResourceTestMockFetchContext() { } 104 virtual ~ImageResourceTestMockFetchContext() { }
103 105
104 bool allowImage(bool imagesEnabled, const KURL&) const override { return tru e; } 106 bool allowImage(bool imagesEnabled, const KURL&) const override { return tru e; }
105 bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const R esourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const o verride { return true; } 107 bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const R esourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const o verride { return true; }
106 bool shouldLoadNewResource(Resource::Type) const override { return true; } 108 bool shouldLoadNewResource(Resource::Type) const override { return true; }
107 WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); } 109 WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); }
108 110
109 private: 111 private:
110 ImageResourceTestMockFetchContext() 112 ImageResourceTestMockFetchContext()
111 : m_runner(adoptPtr(new MockTaskRunner)) 113 : m_runner(wrapUnique(new MockTaskRunner))
112 { } 114 { }
113 115
114 OwnPtr<MockTaskRunner> m_runner; 116 std::unique_ptr<MockTaskRunner> m_runner;
115 }; 117 };
116 118
117 TEST(ImageResourceTest, MultipartImage) 119 TEST(ImageResourceTest, MultipartImage)
118 { 120 {
119 ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetc hContext::create()); 121 ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetc hContext::create());
120 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 122 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
121 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html "); 123 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html ");
122 124
123 // Emulate starting a real load, but don't expect any "real" WebURLLoaderCli ent callbacks. 125 // Emulate starting a real load, but don't expect any "real" WebURLLoaderCli ent callbacks.
124 ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL)) ; 126 ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL)) ;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*> (jpeg.data()), jpeg.size(), jpeg.size()); 297 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*> (jpeg.data()), jpeg.size(), jpeg.size());
296 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size()); 298 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size());
297 ASSERT_FALSE(cachedImage->errorOccurred()); 299 ASSERT_FALSE(cachedImage->errorOccurred());
298 ASSERT_TRUE(cachedImage->hasImage()); 300 ASSERT_TRUE(cachedImage->hasImage());
299 ASSERT_FALSE(cachedImage->getImage()->isNull()); 301 ASSERT_FALSE(cachedImage->getImage()->isNull());
300 ASSERT_TRUE(client->notifyFinishedCalled()); 302 ASSERT_TRUE(client->notifyFinishedCalled());
301 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 303 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
302 } 304 }
303 305
304 } // namespace blink 306 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698