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

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

Issue 2514323004: Convert NaCl renderer-browser messages to mojo. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « components/nacl/browser/pnacl_host.cc ('k') | components/nacl/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 host_->InitForTest(temp_dir_.GetPath(), 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(base::File file, bool is_hit) {
73 EXPECT_FALSE(is_hit); 73 EXPECT_FALSE(is_hit);
74 ASSERT_TRUE(file.IsValid()); 74 ASSERT_TRUE(file.IsValid());
75 base::File::Info info; 75 base::File::Info info;
76 base::File* mutable_file = const_cast<base::File*>(&file); 76 base::File* mutable_file = const_cast<base::File*>(&file);
77 EXPECT_TRUE(mutable_file->GetInfo(&info)); 77 EXPECT_TRUE(mutable_file->GetInfo(&info));
78 EXPECT_FALSE(info.is_directory); 78 EXPECT_FALSE(info.is_directory);
79 EXPECT_EQ(0LL, info.size); 79 EXPECT_EQ(0LL, info.size);
80 char str[kBufferSize]; 80 char str[kBufferSize];
81 memset(str, 0x0, kBufferSize); 81 memset(str, 0x0, kBufferSize);
82 snprintf(str, kBufferSize, "testdata%d", ++write_callback_count_); 82 snprintf(str, kBufferSize, "testdata%d", ++write_callback_count_);
83 EXPECT_EQ(kBufferSize, 83 EXPECT_EQ(kBufferSize,
84 static_cast<size_t>(mutable_file->Write(0, str, kBufferSize))); 84 static_cast<size_t>(mutable_file->Write(0, str, kBufferSize)));
85 temp_callback_count_++; 85 temp_callback_count_++;
86 } 86 }
87 void CallbackExpectHit(const base::File& file, bool is_hit) { 87 void CallbackExpectHit(base::File file, bool is_hit) {
88 EXPECT_TRUE(is_hit); 88 EXPECT_TRUE(is_hit);
89 ASSERT_TRUE(file.IsValid()); 89 ASSERT_TRUE(file.IsValid());
90 base::File::Info info; 90 base::File::Info info;
91 base::File* mutable_file = const_cast<base::File*>(&file); 91 base::File* mutable_file = const_cast<base::File*>(&file);
92 EXPECT_TRUE(mutable_file->GetInfo(&info)); 92 EXPECT_TRUE(mutable_file->GetInfo(&info));
93 EXPECT_FALSE(info.is_directory); 93 EXPECT_FALSE(info.is_directory);
94 EXPECT_EQ(kBufferSize, static_cast<size_t>(info.size)); 94 EXPECT_EQ(kBufferSize, static_cast<size_t>(info.size));
95 char data[kBufferSize]; 95 char data[kBufferSize];
96 memset(data, 0x0, kBufferSize); 96 memset(data, 0x0, kBufferSize);
97 char str[kBufferSize]; 97 char str[kBufferSize];
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Since there's no easy way to pump message queues one message at a time, we 455 // Since there's no easy way to pump message queues one message at a time, we
456 // have to simulate what would happen if 1 DeInitIfsafe task gets queued, then 456 // have to simulate what would happen if 1 DeInitIfsafe task gets queued, then
457 // a GetNexeFd gets queued, and then another DeInitIfSafe gets queued before 457 // a GetNexeFd gets queued, and then another DeInitIfSafe gets queued before
458 // the first one runs. We can just shortcut and call DeInitIfSafe while the 458 // the first one runs. We can just shortcut and call DeInitIfSafe while the
459 // cache is still initializing. 459 // cache is still initializing.
460 DeInit(); 460 DeInit();
461 base::RunLoop().RunUntilIdle(); 461 base::RunLoop().RunUntilIdle();
462 } 462 }
463 463
464 } // namespace pnacl 464 } // namespace pnacl
OLDNEW
« no previous file with comments | « components/nacl/browser/pnacl_host.cc ('k') | components/nacl/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698