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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
| 184 raw->finish(); |
185 EXPECT_FALSE(raw->response().isNull()); | 185 EXPECT_FALSE(raw->response().isNull()); |
186 | 186 |
187 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); | 187 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); |
188 OwnPtr<AddingClient> addingClient = adoptPtr(new AddingClient(dummyClient.ge
t(), raw.get())); | 188 OwnPtr<AddingClient> addingClient = adoptPtr(new AddingClient(dummyClient.ge
t(), raw.get())); |
189 raw->addClient(addingClient.get()); | 189 raw->addClient(addingClient.get()); |
190 testing::runPendingTasks(); | 190 testing::runPendingTasks(); |
191 raw->removeClient(addingClient.get()); | 191 raw->removeClient(addingClient.get()); |
192 EXPECT_FALSE(dummyClient->called()); | 192 EXPECT_FALSE(dummyClient->called()); |
193 EXPECT_FALSE(raw->hasClients()); | 193 EXPECT_FALSE(raw->hasClients()); |
194 } | 194 } |
(...skipping 13 matching lines...) Expand all Loading... |
208 resource->removeClient(this); | 208 resource->removeClient(this); |
209 } | 209 } |
210 String debugName() const override { return "RemovingClient"; } | 210 String debugName() const override { return "RemovingClient"; } |
211 private: | 211 private: |
212 DummyClient* m_dummyClient; | 212 DummyClient* m_dummyClient; |
213 }; | 213 }; |
214 | 214 |
215 TEST(RawResourceTest, RemoveClientDuringCallback) | 215 TEST(RawResourceTest, RemoveClientDuringCallback) |
216 { | 216 { |
217 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data
:text/html,"), Resource::Raw); | 217 RefPtrWillBeRawPtr<Resource> raw = RawResource::create(ResourceRequest("data
:text/html,"), Resource::Raw); |
218 raw->setLoading(false); | |
219 | 218 |
220 // Create a non-null response. | 219 // Create a non-null response. |
221 ResourceResponse response = raw->response(); | 220 ResourceResponse response = raw->response(); |
222 response.setURL(KURL(ParsedURLString, "http://600.613/")); | 221 response.setURL(KURL(ParsedURLString, "http://600.613/")); |
223 raw->setResponse(response); | 222 raw->setResponse(response); |
| 223 raw->finish(); |
224 EXPECT_FALSE(raw->response().isNull()); | 224 EXPECT_FALSE(raw->response().isNull()); |
225 | 225 |
226 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); | 226 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); |
227 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli
ent.get())); | 227 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli
ent.get())); |
228 raw->addClient(dummyClient.get()); | 228 raw->addClient(dummyClient.get()); |
229 raw->addClient(removingClient.get()); | 229 raw->addClient(removingClient.get()); |
230 testing::runPendingTasks(); | 230 testing::runPendingTasks(); |
231 EXPECT_FALSE(raw->hasClients()); | 231 EXPECT_FALSE(raw->hasClients()); |
232 } | 232 } |
233 | 233 |
234 } // namespace blink | 234 } // namespace blink |
OLD | NEW |