| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); | 547 ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); |
| 548 resource2->setCacheIdentifier("foo"); | 548 resource2->setCacheIdentifier("foo"); |
| 549 memoryCache()->add(resource2.get()); | 549 memoryCache()->add(resource2.get()); |
| 550 EXPECT_TRUE(memoryCache()->contains(resource1.get())); | 550 EXPECT_TRUE(memoryCache()->contains(resource1.get())); |
| 551 EXPECT_TRUE(memoryCache()->contains(resource2.get())); | 551 EXPECT_TRUE(memoryCache()->contains(resource2.get())); |
| 552 | 552 |
| 553 const KURL url = KURL(ParsedURLString, "http://test/resource"); | 553 const KURL url = KURL(ParsedURLString, "http://test/resource"); |
| 554 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url)); | 554 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url)); |
| 555 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url, memoryCache()-
>defaultCacheIdentifier())); | 555 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url, memoryCache()-
>defaultCacheIdentifier())); |
| 556 EXPECT_EQ(resource2.get(), memoryCache()->resourceForURL(url, "foo")); | 556 EXPECT_EQ(resource2.get(), memoryCache()->resourceForURL(url, "foo")); |
| 557 EXPECT_EQ(0, memoryCache()->resourceForURL(KURL())); |
| 557 | 558 |
| 558 ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); | 559 ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); |
| 559 resource3->setCacheIdentifier("foo"); | 560 resource3->setCacheIdentifier("foo"); |
| 560 memoryCache()->remove(resource2.get()); | 561 memoryCache()->remove(resource2.get()); |
| 561 memoryCache()->add(resource3.get()); | 562 memoryCache()->add(resource3.get()); |
| 562 EXPECT_TRUE(memoryCache()->contains(resource1.get())); | 563 EXPECT_TRUE(memoryCache()->contains(resource1.get())); |
| 563 EXPECT_FALSE(memoryCache()->contains(resource2.get())); | 564 EXPECT_FALSE(memoryCache()->contains(resource2.get())); |
| 564 EXPECT_TRUE(memoryCache()->contains(resource3.get())); | 565 EXPECT_TRUE(memoryCache()->contains(resource3.get())); |
| 565 | 566 |
| 566 ResourcePtr<FakeResource> resource4 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); | 567 ResourcePtr<FakeResource> resource4 = new FakeResource(ResourceRequest("http
://test/resource"), Resource::Raw); |
| 567 resource4->setCacheIdentifier("foo"); | 568 resource4->setCacheIdentifier("foo"); |
| 568 memoryCache()->replace(resource4.get(), resource3.get()); | 569 memoryCache()->replace(resource4.get(), resource3.get()); |
| 569 EXPECT_TRUE(memoryCache()->contains(resource1.get())); | 570 EXPECT_TRUE(memoryCache()->contains(resource1.get())); |
| 570 EXPECT_FALSE(memoryCache()->contains(resource3.get())); | 571 EXPECT_FALSE(memoryCache()->contains(resource3.get())); |
| 571 EXPECT_TRUE(memoryCache()->contains(resource4.get())); | 572 EXPECT_TRUE(memoryCache()->contains(resource4.get())); |
| 572 | 573 |
| 573 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); | 574 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); |
| 574 EXPECT_EQ(2u, resources.size()); | 575 EXPECT_EQ(2u, resources.size()); |
| 575 | 576 |
| 576 memoryCache()->evictResources(); | 577 memoryCache()->evictResources(); |
| 577 EXPECT_FALSE(memoryCache()->contains(resource1.get())); | 578 EXPECT_FALSE(memoryCache()->contains(resource1.get())); |
| 578 EXPECT_FALSE(memoryCache()->contains(resource3.get())); | 579 EXPECT_FALSE(memoryCache()->contains(resource3.get())); |
| 579 } | 580 } |
| 580 | 581 |
| 581 } // namespace | 582 } // namespace |
| OLD | NEW |