| 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 "components/nacl/browser/pnacl_translation_cache.h" | 5 #include "components/nacl/browser/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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 static const std::string test_store_val("testnexe"); | 128 static const std::string test_store_val("testnexe"); |
| 129 static const int kLargeNexeSize = 8 * 1024 * 1024; | 129 static const int kLargeNexeSize = 8 * 1024 * 1024; |
| 130 | 130 |
| 131 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) { | 131 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) { |
| 132 nacl::PnaclCacheInfo info; | 132 nacl::PnaclCacheInfo info; |
| 133 info.pexe_url = GURL("http://www.google.com"); | 133 info.pexe_url = GURL("http://www.google.com"); |
| 134 info.abi_version = 0; | 134 info.abi_version = 0; |
| 135 info.opt_level = 0; | 135 info.opt_level = 0; |
| 136 info.sandbox_isa = "x86-32"; | 136 info.sandbox_isa = "x86-32"; |
| 137 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT"); | 137 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT"); |
| 138 base::Time::FromString(test_time.c_str(), &info.last_modified); | 138 EXPECT_TRUE(base::Time::FromString(test_time.c_str(), &info.last_modified)); |
| 139 // Basic check for URL and time components | 139 // Basic check for URL and time components |
| 140 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;" | 140 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;" |
| 141 "modified:1995:11:15:6:25:24:0:UTC;etag:;" | 141 "modified:1995:11:15:6:25:24:0:UTC;etag:;" |
| 142 "sandbox:x86-32;extra_flags:;", | 142 "sandbox:x86-32;extra_flags:;", |
| 143 PnaclTranslationCache::GetKey(info)); | 143 PnaclTranslationCache::GetKey(info)); |
| 144 // Check that query portion of URL is not stripped | 144 // Check that query portion of URL is not stripped |
| 145 info.pexe_url = GURL("http://www.google.com/?foo=bar"); | 145 info.pexe_url = GURL("http://www.google.com/?foo=bar"); |
| 146 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/?foo=bar;" | 146 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/?foo=bar;" |
| 147 "modified:1995:11:15:6:25:24:0:UTC;etag:;" | 147 "modified:1995:11:15:6:25:24:0:UTC;etag:;" |
| 148 "sandbox:x86-32;extra_flags:;", | 148 "sandbox:x86-32;extra_flags:;", |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 "sandbox:x86-32;extra_flags:-mavx-neon;", | 197 "sandbox:x86-32;extra_flags:-mavx-neon;", |
| 198 PnaclTranslationCache::GetKey(info)); | 198 PnaclTranslationCache::GetKey(info)); |
| 199 | 199 |
| 200 // Check for all the time components, and null time | 200 // Check for all the time components, and null time |
| 201 info.last_modified = base::Time(); | 201 info.last_modified = base::Time(); |
| 202 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" | 202 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" |
| 203 "modified:0:0:0:0:0:0:0:UTC;etag:etag;" | 203 "modified:0:0:0:0:0:0:0:UTC;etag:etag;" |
| 204 "sandbox:x86-32;extra_flags:-mavx-neon;", | 204 "sandbox:x86-32;extra_flags:-mavx-neon;", |
| 205 PnaclTranslationCache::GetKey(info)); | 205 PnaclTranslationCache::GetKey(info)); |
| 206 test_time.assign("Fri, 29 Feb 2008 13:04:12 GMT"); | 206 test_time.assign("Fri, 29 Feb 2008 13:04:12 GMT"); |
| 207 base::Time::FromString(test_time.c_str(), &info.last_modified); | 207 EXPECT_TRUE(base::Time::FromString(test_time.c_str(), &info.last_modified)); |
| 208 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" | 208 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" |
| 209 "modified:2008:2:29:13:4:12:0:UTC;etag:etag;" | 209 "modified:2008:2:29:13:4:12:0:UTC;etag:etag;" |
| 210 "sandbox:x86-32;extra_flags:-mavx-neon;", | 210 "sandbox:x86-32;extra_flags:-mavx-neon;", |
| 211 PnaclTranslationCache::GetKey(info)); | 211 PnaclTranslationCache::GetKey(info)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 TEST_F(PnaclTranslationCacheTest, StoreSmallInMem) { | 214 TEST_F(PnaclTranslationCacheTest, StoreSmallInMem) { |
| 215 // Test that a single store puts something in the mem backend | 215 // Test that a single store puts something in the mem backend |
| 216 InitBackend(true); | 216 InitBackend(true); |
| 217 StoreNexe(test_key, test_store_val); | 217 StoreNexe(test_key, test_store_val); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 StoreNexe(test_key, test_store_val); | 295 StoreNexe(test_key, test_store_val); |
| 296 TestNexeCallback load_cb; | 296 TestNexeCallback load_cb; |
| 297 std::string nexe; | 297 std::string nexe; |
| 298 cache_->GetNexe(test_key + "a", load_cb.callback()); | 298 cache_->GetNexe(test_key + "a", load_cb.callback()); |
| 299 int rv; | 299 int rv; |
| 300 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); | 300 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); |
| 301 EXPECT_EQ(net::ERR_FAILED, rv); | 301 EXPECT_EQ(net::ERR_FAILED, rv); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace pnacl | 304 } // namespace pnacl |
| OLD | NEW |