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

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

Issue 1802123002: Unify Resource loading status tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 resource->removeClient(client.get()); 170 resource->removeClient(client.get());
171 EXPECT_FALSE(resource->hasClients()); 171 EXPECT_FALSE(resource->hasClients());
172 EXPECT_FALSE(client->called()); 172 EXPECT_FALSE(client->called());
173 EXPECT_EQ(0u, client->data().size()); 173 EXPECT_EQ(0u, client->data().size());
174 } 174 }
175 175
176 TEST(RawResourceTest, AddClientDuringCallback) 176 TEST(RawResourceTest, AddClientDuringCallback)
177 { 177 {
178 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data :text/html,"), Resource::Raw); 178 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data :text/html,"), Resource::Raw);
179 raw->setLoading(false);
180 179
181 // Create a non-null response. 180 // Create a non-null response.
182 ResourceResponse response = raw->response(); 181 ResourceResponse response = raw->response();
183 response.setURL(KURL(ParsedURLString, "http://600.613/")); 182 response.setURL(KURL(ParsedURLString, "http://600.613/"));
184 raw->setResponse(response); 183 raw->setResponse(response);
hiroshige 2016/03/18 23:21:20 How about calling raw->finish() for consistency?
Nate Chapin 2016/03/21 22:04:01 Done.
185 EXPECT_FALSE(raw->response().isNull()); 184 EXPECT_FALSE(raw->response().isNull());
186 185
187 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); 186 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient());
188 OwnPtr<AddingClient> addingClient = adoptPtr(new AddingClient(dummyClient.ge t(), raw.get())); 187 OwnPtr<AddingClient> addingClient = adoptPtr(new AddingClient(dummyClient.ge t(), raw.get()));
189 raw->addClient(addingClient.get()); 188 raw->addClient(addingClient.get());
190 testing::runPendingTasks(); 189 testing::runPendingTasks();
191 raw->removeClient(addingClient.get()); 190 raw->removeClient(addingClient.get());
192 EXPECT_FALSE(dummyClient->called()); 191 EXPECT_FALSE(dummyClient->called());
193 EXPECT_FALSE(raw->hasClients()); 192 EXPECT_FALSE(raw->hasClients());
194 } 193 }
(...skipping 13 matching lines...) Expand all
208 resource->removeClient(this); 207 resource->removeClient(this);
209 } 208 }
210 String debugName() const override { return "RemovingClient"; } 209 String debugName() const override { return "RemovingClient"; }
211 private: 210 private:
212 DummyClient* m_dummyClient; 211 DummyClient* m_dummyClient;
213 }; 212 };
214 213
215 TEST(RawResourceTest, RemoveClientDuringCallback) 214 TEST(RawResourceTest, RemoveClientDuringCallback)
216 { 215 {
217 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data :text/html,"), Resource::Raw); 216 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data :text/html,"), Resource::Raw);
218 raw->setLoading(false);
219 217
220 // Create a non-null response. 218 // Create a non-null response.
221 ResourceResponse response = raw->response(); 219 ResourceResponse response = raw->response();
222 response.setURL(KURL(ParsedURLString, "http://600.613/")); 220 response.setURL(KURL(ParsedURLString, "http://600.613/"));
223 raw->setResponse(response); 221 raw->setResponse(response);
222 raw->finish();
224 EXPECT_FALSE(raw->response().isNull()); 223 EXPECT_FALSE(raw->response().isNull());
225 224
226 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); 225 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient());
227 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli ent.get())); 226 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli ent.get()));
228 raw->addClient(dummyClient.get()); 227 raw->addClient(dummyClient.get());
229 raw->addClient(removingClient.get()); 228 raw->addClient(removingClient.get());
230 testing::runPendingTasks(); 229 testing::runPendingTasks();
231 EXPECT_FALSE(raw->hasClients()); 230 EXPECT_FALSE(raw->hasClients());
232 } 231 }
233 232
234 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698