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

Side by Side Diff: Source/core/fetch/RawResourceTest.cpp

Issue 1327653004: Have uses of MockImageResourceClient leak less. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up MockImageResourceClient somewhat Created 5 years, 3 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 25 matching lines...) Expand all
36 #include "core/fetch/MockImageResourceClient.h" 36 #include "core/fetch/MockImageResourceClient.h"
37 #include "core/fetch/ResourceFetcher.h" 37 #include "core/fetch/ResourceFetcher.h"
38 #include "core/fetch/ResourcePtr.h" 38 #include "core/fetch/ResourcePtr.h"
39 #include "platform/SharedBuffer.h" 39 #include "platform/SharedBuffer.h"
40 #include "platform/testing/UnitTestHelpers.h" 40 #include "platform/testing/UnitTestHelpers.h"
41 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
42 #include "public/platform/WebURL.h" 42 #include "public/platform/WebURL.h"
43 #include "public/platform/WebURLResponse.h" 43 #include "public/platform/WebURLResponse.h"
44 #include "public/platform/WebUnitTestSupport.h" 44 #include "public/platform/WebUnitTestSupport.h"
45 45
46 #include <gtest/gtest.h>
47
46 namespace blink { 48 namespace blink {
47 49
48 TEST(RawResourceTest, DontIgnoreAcceptForCacheReuse) 50 TEST(RawResourceTest, DontIgnoreAcceptForCacheReuse)
49 { 51 {
50 ResourceRequest jpegRequest; 52 ResourceRequest jpegRequest;
51 jpegRequest.setHTTPAccept("image/jpeg"); 53 jpegRequest.setHTTPAccept("image/jpeg");
52 54
53 ResourcePtr<RawResource> jpegResource(new RawResource(jpegRequest, Resource: :Raw)); 55 ResourcePtr<RawResource> jpegResource(new RawResource(jpegRequest, Resource: :Raw));
54 56
55 ResourceRequest pngRequest; 57 ResourceRequest pngRequest;
(...skipping 17 matching lines...) Expand all
73 // Simulate a successful revalidation. 75 // Simulate a successful revalidation.
74 // The revalidated resource (oldResource) should now be in the cache, newRes ource 76 // The revalidated resource (oldResource) should now be in the cache, newRes ource
75 // should have been sliently switched to point to the revalidated resource, and 77 // should have been sliently switched to point to the revalidated resource, and
76 // we shouldn't hit any ASSERTs. 78 // we shouldn't hit any ASSERTs.
77 ResourceResponse response; 79 ResourceResponse response;
78 response.setHTTPStatusCode(304); 80 response.setHTTPStatusCode(304);
79 newResource->responseReceived(response, nullptr); 81 newResource->responseReceived(response, nullptr);
80 EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/htm l,")), oldResource.get()); 82 EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/htm l,")), oldResource.get());
81 EXPECT_EQ(oldResource.get(), newResource.get()); 83 EXPECT_EQ(oldResource.get(), newResource.get());
82 EXPECT_NE(newResource.get(), newResourcePointer); 84 EXPECT_NE(newResource.get(), newResourcePointer);
85 memoryCache()->remove(newResource.get());
83 } 86 }
84 87
85 class DummyClient : public RawResourceClient { 88 class DummyClient : public RawResourceClient {
86 public: 89 public:
87 DummyClient() : m_called(false) {} 90 DummyClient() : m_called(false) {}
88 ~DummyClient() override {} 91 ~DummyClient() override {}
89 92
90 // ResourceClient implementation. 93 // ResourceClient implementation.
91 virtual void notifyFinished(Resource* resource) 94 virtual void notifyFinished(Resource* resource)
92 { 95 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 180
178 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); 181 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient());
179 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli ent.get())); 182 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli ent.get()));
180 raw->addClient(dummyClient.get()); 183 raw->addClient(dummyClient.get());
181 raw->addClient(removingClient.get()); 184 raw->addClient(removingClient.get());
182 testing::runPendingTasks(); 185 testing::runPendingTasks();
183 EXPECT_FALSE(raw->hasClients()); 186 EXPECT_FALSE(raw->hasClients());
184 } 187 }
185 188
186 } // namespace blink 189 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/MockImageResourceClient.cpp ('k') | Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698