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

Side by Side Diff: components/nacl/browser/pnacl_host_unittest.cc

Issue 2318033002: c/browser, c/common, components M-N: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix ItunesFileUtilTest Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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_host.h" 5 #include "components/nacl/browser/pnacl_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 class PnaclHostTest : public testing::Test { 36 class PnaclHostTest : public testing::Test {
37 protected: 37 protected:
38 PnaclHostTest() 38 PnaclHostTest()
39 : host_(NULL), 39 : host_(NULL),
40 temp_callback_count_(0), 40 temp_callback_count_(0),
41 write_callback_count_(0), 41 write_callback_count_(0),
42 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 42 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
43 void SetUp() override { 43 void SetUp() override {
44 host_ = PnaclHost::GetInstance(); 44 host_ = PnaclHost::GetInstance();
45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
46 host_->InitForTest(temp_dir_.path(), true); 46 host_->InitForTest(temp_dir_.GetPath(), true);
47 base::RunLoop().RunUntilIdle(); 47 base::RunLoop().RunUntilIdle();
48 EXPECT_EQ(PnaclHost::CacheReady, host_->cache_state_); 48 EXPECT_EQ(PnaclHost::CacheReady, host_->cache_state_);
49 } 49 }
50 void TearDown() override { 50 void TearDown() override {
51 EXPECT_EQ(0U, host_->pending_translations()); 51 EXPECT_EQ(0U, host_->pending_translations());
52 // Give the host a chance to de-init the backend, and then delete it. 52 // Give the host a chance to de-init the backend, and then delete it.
53 host_->RendererClosing(0); 53 host_->RendererClosing(0);
54 content::RunAllBlockingPoolTasksUntilIdle(); 54 content::RunAllBlockingPoolTasksUntilIdle();
55 EXPECT_EQ(PnaclHost::CacheUninitialized, host_->cache_state_); 55 EXPECT_EQ(PnaclHost::CacheUninitialized, host_->cache_state_);
56 } 56 }
57 int GetCacheSize() { return host_->disk_cache_->Size(); } 57 int GetCacheSize() { return host_->disk_cache_->Size(); }
58 int CacheIsInitialized() { 58 int CacheIsInitialized() {
59 return host_->cache_state_ == PnaclHost::CacheReady; 59 return host_->cache_state_ == PnaclHost::CacheReady;
60 } 60 }
61 void ReInitBackend() { 61 void ReInitBackend() {
62 host_->InitForTest(temp_dir_.path(), true); 62 host_->InitForTest(temp_dir_.GetPath(), true);
63 base::RunLoop().RunUntilIdle(); 63 base::RunLoop().RunUntilIdle();
64 EXPECT_EQ(PnaclHost::CacheReady, host_->cache_state_); 64 EXPECT_EQ(PnaclHost::CacheReady, host_->cache_state_);
65 } 65 }
66 66
67 public: // Required for derived classes to bind this method 67 public: // Required for derived classes to bind this method
68 // Callbacks used by tests which call GetNexeFd. 68 // Callbacks used by tests which call GetNexeFd.
69 // CallbackExpectMiss checks that the fd is valid and a miss is reported, 69 // CallbackExpectMiss checks that the fd is valid and a miss is reported,
70 // and also writes some data into the file, which is read back by 70 // and also writes some data into the file, which is read back by
71 // CallbackExpectHit 71 // CallbackExpectHit
72 void CallbackExpectMiss(const base::File& file, bool is_hit) { 72 void CallbackExpectMiss(const base::File& file, bool is_hit) {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Now check that the backend has been freed. 435 // Now check that the backend has been freed.
436 EXPECT_FALSE(CacheIsInitialized()); 436 EXPECT_FALSE(CacheIsInitialized());
437 } 437 }
438 438
439 // A version of PnaclHostTest that initializes cache on disk. 439 // A version of PnaclHostTest that initializes cache on disk.
440 class PnaclHostTestDisk : public PnaclHostTest { 440 class PnaclHostTestDisk : public PnaclHostTest {
441 protected: 441 protected:
442 void SetUp() override { 442 void SetUp() override {
443 host_ = PnaclHost::GetInstance(); 443 host_ = PnaclHost::GetInstance();
444 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 444 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
445 host_->InitForTest(temp_dir_.path(), false); 445 host_->InitForTest(temp_dir_.GetPath(), false);
446 EXPECT_EQ(PnaclHost::CacheInitializing, host_->cache_state_); 446 EXPECT_EQ(PnaclHost::CacheInitializing, host_->cache_state_);
447 } 447 }
448 void DeInit() { 448 void DeInit() {
449 host_->DeInitIfSafe(); 449 host_->DeInitIfSafe();
450 } 450 }
451 }; 451 };
452 TEST_F(PnaclHostTestDisk, DeInitWhileInitializing) { 452 TEST_F(PnaclHostTestDisk, DeInitWhileInitializing) {
453 // Since there's no easy way to pump message queues one message at a time, we 453 // Since there's no easy way to pump message queues one message at a time, we
454 // have to simulate what would happen if 1 DeInitIfsafe task gets queued, then 454 // have to simulate what would happen if 1 DeInitIfsafe task gets queued, then
455 // a GetNexeFd gets queued, and then another DeInitIfSafe gets queued before 455 // a GetNexeFd gets queued, and then another DeInitIfSafe gets queued before
456 // the first one runs. We can just shortcut and call DeInitIfSafe while the 456 // the first one runs. We can just shortcut and call DeInitIfSafe while the
457 // cache is still initializing. 457 // cache is still initializing.
458 DeInit(); 458 DeInit();
459 base::RunLoop().RunUntilIdle(); 459 base::RunLoop().RunUntilIdle();
460 } 460 }
461 461
462 } // namespace pnacl 462 } // namespace pnacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698