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

Unified Diff: components/html_viewer/discardable_memory_allocator_unittest.cc

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/html_viewer/discardable_memory_allocator_unittest.cc
diff --git a/components/html_viewer/discardable_memory_allocator_unittest.cc b/components/html_viewer/discardable_memory_allocator_unittest.cc
deleted file mode 100644
index a4b19ae761f8f9067e35bef38dac8831fe5654e6..0000000000000000000000000000000000000000
--- a/components/html_viewer/discardable_memory_allocator_unittest.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/html_viewer/discardable_memory_allocator.h"
-
-#include <stddef.h>
-
-#include "base/memory/discardable_memory.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace html_viewer {
-namespace {
-
-const size_t kOneKilobyte = 1024;
-const size_t kAlmostOneMegabyte = 1023 * kOneKilobyte;
-const size_t kOneMegabyte = 1024 * kOneKilobyte;
-
-TEST(DiscardableMemoryAllocator, Basic) {
- DiscardableMemoryAllocator allocator(kOneMegabyte);
- scoped_ptr<base::DiscardableMemory> chunk;
- // Make sure the chunk is locked when allocated. In debug mode, we will
- // dcheck.
- chunk = allocator.AllocateLockedDiscardableMemory(kOneKilobyte);
- chunk->Unlock();
-
- // Make sure we can lock a chunk.
- EXPECT_TRUE(chunk->Lock());
- chunk->Unlock();
-}
-
-TEST(DiscardableMemoryAllocator, DiscardChunks) {
- DiscardableMemoryAllocator allocator(kOneMegabyte);
-
- scoped_ptr<base::DiscardableMemory> chunk_to_remove =
- allocator.AllocateLockedDiscardableMemory(kAlmostOneMegabyte);
- chunk_to_remove->Unlock();
-
- // Allocating a second chunk should deallocate the first one due to memory
- // pressure, since we only have one megabyte available.
- scoped_ptr<base::DiscardableMemory> chunk_to_keep =
- allocator.AllocateLockedDiscardableMemory(kAlmostOneMegabyte);
-
- // Fail to get a lock because allocating the second chunk removed the first.
- EXPECT_FALSE(chunk_to_remove->Lock());
-
- chunk_to_keep->Unlock();
-}
-
-TEST(DiscardableMemoryAllocator, DontDiscardLiveChunks) {
- DiscardableMemoryAllocator allocator(kOneMegabyte);
-
- scoped_ptr<base::DiscardableMemory> chunk_one =
- allocator.AllocateLockedDiscardableMemory(kAlmostOneMegabyte);
- scoped_ptr<base::DiscardableMemory> chunk_two =
- allocator.AllocateLockedDiscardableMemory(kAlmostOneMegabyte);
- scoped_ptr<base::DiscardableMemory> chunk_three =
- allocator.AllocateLockedDiscardableMemory(kAlmostOneMegabyte);
-
- // These accesses will fail if the underlying weak ptr has been deallocated.
- EXPECT_NE(nullptr, chunk_one->data());
- EXPECT_NE(nullptr, chunk_two->data());
- EXPECT_NE(nullptr, chunk_three->data());
-
- chunk_one->Unlock();
- chunk_two->Unlock();
- chunk_three->Unlock();
-}
-
-} // namespace
-} // namespace html_viewer
« no previous file with comments | « components/html_viewer/discardable_memory_allocator.cc ('k') | components/html_viewer/document_resource_waiter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698