| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/nacl_host/pnacl_translation_cache.h" | 5 #include "chrome/browser/nacl_host/pnacl_translation_cache.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 EXPECT_EQ(1, cache_->Size()); | 180 EXPECT_EQ(1, cache_->Size()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST_F(PnaclTranslationCacheTest, StoreSmallOnDisk) { | 183 TEST_F(PnaclTranslationCacheTest, StoreSmallOnDisk) { |
| 184 // Test that a single store puts something in the disk backend | 184 // Test that a single store puts something in the disk backend |
| 185 InitBackend(false); | 185 InitBackend(false); |
| 186 StoreNexe(test_key, test_store_val); | 186 StoreNexe(test_key, test_store_val); |
| 187 EXPECT_EQ(1, cache_->Size()); | 187 EXPECT_EQ(1, cache_->Size()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 #if defined(OS_LINUX) |
| 191 TEST_F(PnaclTranslationCacheTest, DISABLED_StoreLargeOnDisk) { |
| 192 #else |
| 190 TEST_F(PnaclTranslationCacheTest, StoreLargeOnDisk) { | 193 TEST_F(PnaclTranslationCacheTest, StoreLargeOnDisk) { |
| 194 #endif |
| 191 // Test a value too large(?) for a single I/O operation | 195 // Test a value too large(?) for a single I/O operation |
| 192 InitBackend(false); | 196 InitBackend(false); |
| 193 const std::string large_buffer(kLargeNexeSize, 'a'); | 197 const std::string large_buffer(kLargeNexeSize, 'a'); |
| 194 StoreNexe(test_key, large_buffer); | 198 StoreNexe(test_key, large_buffer); |
| 195 EXPECT_EQ(1, cache_->Size()); | 199 EXPECT_EQ(1, cache_->Size()); |
| 196 } | 200 } |
| 197 | 201 |
| 198 TEST_F(PnaclTranslationCacheTest, InMemSizeLimit) { | 202 TEST_F(PnaclTranslationCacheTest, InMemSizeLimit) { |
| 199 InitBackend(true); | 203 InitBackend(true); |
| 200 scoped_refptr<net::DrainableIOBuffer> large_buffer(new net::DrainableIOBuffer( | 204 scoped_refptr<net::DrainableIOBuffer> large_buffer(new net::DrainableIOBuffer( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 214 EXPECT_EQ(0, GetNexe(test_key).compare(test_store_val)); | 218 EXPECT_EQ(0, GetNexe(test_key).compare(test_store_val)); |
| 215 } | 219 } |
| 216 | 220 |
| 217 TEST_F(PnaclTranslationCacheTest, GetOneOnDisk) { | 221 TEST_F(PnaclTranslationCacheTest, GetOneOnDisk) { |
| 218 InitBackend(false); | 222 InitBackend(false); |
| 219 StoreNexe(test_key, test_store_val); | 223 StoreNexe(test_key, test_store_val); |
| 220 EXPECT_EQ(1, cache_->Size()); | 224 EXPECT_EQ(1, cache_->Size()); |
| 221 EXPECT_EQ(0, GetNexe(test_key).compare(test_store_val)); | 225 EXPECT_EQ(0, GetNexe(test_key).compare(test_store_val)); |
| 222 } | 226 } |
| 223 | 227 |
| 228 #if defined(OS_LINUX) |
| 229 TEST_F(PnaclTranslationCacheTest, DISABLED_GetLargeOnDisk) { |
| 230 #else |
| 224 TEST_F(PnaclTranslationCacheTest, GetLargeOnDisk) { | 231 TEST_F(PnaclTranslationCacheTest, GetLargeOnDisk) { |
| 232 #endif |
| 225 InitBackend(false); | 233 InitBackend(false); |
| 226 const std::string large_buffer(kLargeNexeSize, 'a'); | 234 const std::string large_buffer(kLargeNexeSize, 'a'); |
| 227 StoreNexe(test_key, large_buffer); | 235 StoreNexe(test_key, large_buffer); |
| 228 EXPECT_EQ(1, cache_->Size()); | 236 EXPECT_EQ(1, cache_->Size()); |
| 229 EXPECT_EQ(0, GetNexe(test_key).compare(large_buffer)); | 237 EXPECT_EQ(0, GetNexe(test_key).compare(large_buffer)); |
| 230 } | 238 } |
| 231 | 239 |
| 232 TEST_F(PnaclTranslationCacheTest, StoreTwice) { | 240 TEST_F(PnaclTranslationCacheTest, StoreTwice) { |
| 233 // Test that storing twice with the same key overwrites | 241 // Test that storing twice with the same key overwrites |
| 234 InitBackend(true); | 242 InitBackend(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 252 StoreNexe(test_key, test_store_val); | 260 StoreNexe(test_key, test_store_val); |
| 253 TestNexeCallback load_cb; | 261 TestNexeCallback load_cb; |
| 254 std::string nexe; | 262 std::string nexe; |
| 255 cache_->GetNexe(test_key + "a", load_cb.callback()); | 263 cache_->GetNexe(test_key + "a", load_cb.callback()); |
| 256 int rv; | 264 int rv; |
| 257 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); | 265 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); |
| 258 EXPECT_EQ(net::ERR_FAILED, rv); | 266 EXPECT_EQ(net::ERR_FAILED, rv); |
| 259 } | 267 } |
| 260 | 268 |
| 261 } // namespace pnacl | 269 } // namespace pnacl |
| OLD | NEW |