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

Side by Side Diff: chrome/nacl/nacl_ipc_adapter_unittest.cc

Issue 15274002: Do not translate the file open flags other than read/write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_rel build Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/nacl/nacl_ipc_adapter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/nacl/nacl_ipc_adapter.h" 5 #include "chrome/nacl/nacl_ipc_adapter.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/threading/simple_thread.h" 13 #include "base/threading/simple_thread.h"
14 #include "ipc/ipc_test_sink.h" 14 #include "ipc/ipc_test_sink.h"
15 #include "native_client/src/trusted/desc/nacl_desc_custom.h" 15 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
16 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
17 #include "ppapi/c/ppb_file_io.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 namespace { 20 namespace {
19 21
20 class NaClIPCAdapterTest : public testing::Test { 22 class NaClIPCAdapterTest : public testing::Test {
21 public: 23 public:
22 NaClIPCAdapterTest() {} 24 NaClIPCAdapterTest() {}
23 25
24 // testing::Test implementation. 26 // testing::Test implementation.
25 virtual void SetUp() OVERRIDE { 27 virtual void SetUp() OVERRIDE {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 EXPECT_EQ(-1, result); 301 EXPECT_EQ(-1, result);
300 302
301 // Test the "previously had an error" case. BlockingReceive should return 303 // Test the "previously had an error" case. BlockingReceive should return
302 // immediately if there was an error. 304 // immediately if there was an error.
303 result = BlockingReceive(buf, kBufSize); 305 result = BlockingReceive(buf, kBufSize);
304 EXPECT_EQ(-1, result); 306 EXPECT_EQ(-1, result);
305 307
306 thread.Join(); 308 thread.Join();
307 } 309 }
308 310
311 // Tests that TranslatePepperFileOpenFlags translates pepper read/write open
312 // flags into NaCl open flags correctly.
313 TEST_F(NaClIPCAdapterTest, TranslatePepperFileReadWriteOpenFlags) {
314 EXPECT_EQ(NACL_ABI_O_RDONLY,
315 TranslatePepperFileReadWriteOpenFlagsForTesting(PP_FILEOPENFLAG_READ));
316 EXPECT_EQ(NACL_ABI_O_WRONLY,
317 TranslatePepperFileReadWriteOpenFlagsForTesting(PP_FILEOPENFLAG_WRITE));
318 EXPECT_EQ(NACL_ABI_O_RDWR,
319 TranslatePepperFileReadWriteOpenFlagsForTesting(
320 PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE));
321
322 // The flags other than PP_FILEOPENFLAG_READ and PP_FILEOPENFLAG_WRITE are
323 // discared.
324 EXPECT_EQ(NACL_ABI_O_WRONLY,
325 TranslatePepperFileReadWriteOpenFlagsForTesting(
326 PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_CREATE));
327 EXPECT_EQ(NACL_ABI_O_WRONLY,
328 TranslatePepperFileReadWriteOpenFlagsForTesting(
329 PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_TRUNCATE));
330 EXPECT_EQ(NACL_ABI_O_WRONLY,
331 TranslatePepperFileReadWriteOpenFlagsForTesting(
332 PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_EXCLUSIVE));
333
334 // If neither of PP_FILEOPENFLAG_READ and PP_FILEOPENFLAG_WRITE is set, falls
335 // back NACL_ABI_O_READONLY
336 EXPECT_EQ(NACL_ABI_O_RDONLY,
337 TranslatePepperFileReadWriteOpenFlagsForTesting(PP_FILEOPENFLAG_CREATE));
338 EXPECT_EQ(NACL_ABI_O_RDONLY,
339 TranslatePepperFileReadWriteOpenFlagsForTesting(
340 PP_FILEOPENFLAG_TRUNCATE));
341 EXPECT_EQ(NACL_ABI_O_RDONLY,
342 TranslatePepperFileReadWriteOpenFlagsForTesting(
343 PP_FILEOPENFLAG_EXCLUSIVE));
344 }
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_ipc_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698