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

Side by Side Diff: ppapi/tests/test_file_io.cc

Issue 8764004: Add DEPS include rules so we don't accidentally use base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove rules to include self where possible Created 9 years 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 | « ppapi/tests/test_audio_config.cc ('k') | ppapi/tests/test_flash.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/tests/test_file_io.h" 5 #include "ppapi/tests/test_file_io.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include <vector>
10
10 #include "ppapi/c/dev/ppb_testing_dev.h" 11 #include "ppapi/c/dev/ppb_testing_dev.h"
11 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/ppb_file_io.h" 13 #include "ppapi/c/ppb_file_io.h"
13 #include "ppapi/c/trusted/ppb_file_io_trusted.h" 14 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
14 #include "ppapi/cpp/file_io.h" 15 #include "ppapi/cpp/file_io.h"
15 #include "ppapi/cpp/file_ref.h" 16 #include "ppapi/cpp/file_ref.h"
16 #include "ppapi/cpp/file_system.h" 17 #include "ppapi/cpp/file_system.h"
17 #include "ppapi/cpp/instance.h" 18 #include "ppapi/cpp/instance.h"
18 #include "ppapi/cpp/module.h" 19 #include "ppapi/cpp/module.h"
19 #include "ppapi/tests/test_utils.h" 20 #include "ppapi/tests/test_utils.h"
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if (rv != PP_OK) 691 if (rv != PP_OK)
691 return ReportError("FileIO::Write", rv); 692 return ReportError("FileIO::Write", rv);
692 693
693 // Parallel read operations. 694 // Parallel read operations.
694 const char* border = "__border__"; 695 const char* border = "__border__";
695 const int32_t border_size = strlen(border); 696 const int32_t border_size = strlen(border);
696 697
697 TestCompletionCallback callback_1(instance_->pp_instance(), force_async_); 698 TestCompletionCallback callback_1(instance_->pp_instance(), force_async_);
698 int32_t read_offset_1 = 0; 699 int32_t read_offset_1 = 0;
699 int32_t size_1 = 3; 700 int32_t size_1 = 3;
700 char* extended_buf_1 = new char[border_size * 2 + size_1]; 701 std::vector<char> extended_buf_1(border_size * 2 + size_1);
701 scoped_array<char> extended_buf_1_deleter(extended_buf_1); 702 char* buf_1 = &extended_buf_1[border_size];
702 char* buf_1 = extended_buf_1 + border_size; 703 memcpy(&extended_buf_1[0], border, border_size);
703 memcpy(extended_buf_1, border, border_size);
704 memcpy(buf_1 + size_1, border, border_size); 704 memcpy(buf_1 + size_1, border, border_size);
705 705
706 TestCompletionCallback callback_2(instance_->pp_instance(), force_async_); 706 TestCompletionCallback callback_2(instance_->pp_instance(), force_async_);
707 int32_t read_offset_2 = size_1; 707 int32_t read_offset_2 = size_1;
708 int32_t size_2 = 9; 708 int32_t size_2 = 9;
709 char* extended_buf_2 = new char[border_size * 2 + size_2]; 709 std::vector<char> extended_buf_2(border_size * 2 + size_2);
710 scoped_array<char> extended_buf_2_deleter(extended_buf_2); 710 char* buf_2 = &extended_buf_2[border_size];
711 char* buf_2 = extended_buf_2 + border_size; 711 memcpy(&extended_buf_2[0], border, border_size);
712 memcpy(extended_buf_2, border, border_size);
713 memcpy(buf_2 + size_2, border, border_size); 712 memcpy(buf_2 + size_2, border, border_size);
714 713
715 int32_t rv_1 = PP_OK; 714 int32_t rv_1 = PP_OK;
716 int32_t rv_2 = PP_OK; 715 int32_t rv_2 = PP_OK;
717 while (size_1 >= 0 && size_2 >= 0 && size_1 + size_2 > 0) { 716 while (size_1 >= 0 && size_2 >= 0 && size_1 + size_2 > 0) {
718 if (size_1 > 0) { 717 if (size_1 > 0) {
719 rv_1 = file_io.Read(read_offset_1, buf_1, size_1, callback_1); 718 rv_1 = file_io.Read(read_offset_1, buf_1, size_1, callback_1);
720 if (rv_1 != PP_OK_COMPLETIONPENDING) 719 if (rv_1 != PP_OK_COMPLETIONPENDING)
721 return ReportError("FileIO::Read", rv_1); 720 return ReportError("FileIO::Read", rv_1);
722 } 721 }
(...skipping 26 matching lines...) Expand all
749 // If |size_1| or |size_2| is less than 0, we have invoked wrong 748 // If |size_1| or |size_2| is less than 0, we have invoked wrong
750 // callback(s). 749 // callback(s).
751 if (size_1 < 0 || size_2 < 0) { 750 if (size_1 < 0 || size_2 < 0) {
752 return std::string( 751 return std::string(
753 "Parallel FileIO::Read operations have invoked wrong callbacks."); 752 "Parallel FileIO::Read operations have invoked wrong callbacks.");
754 } 753 }
755 754
756 // Make sure every read operation writes into the correct buffer. 755 // Make sure every read operation writes into the correct buffer.
757 const char expected_result_1[] = "__border__abc__border__"; 756 const char expected_result_1[] = "__border__abc__border__";
758 const char expected_result_2[] = "__border__defghijkl__border__"; 757 const char expected_result_2[] = "__border__defghijkl__border__";
759 if (strncmp(extended_buf_1, expected_result_1, 758 if (strncmp(&extended_buf_1[0], expected_result_1,
760 strlen(expected_result_1)) != 0 || 759 strlen(expected_result_1)) != 0 ||
761 strncmp(extended_buf_2, expected_result_2, 760 strncmp(&extended_buf_2[0], expected_result_2,
762 strlen(expected_result_2)) != 0) { 761 strlen(expected_result_2)) != 0) {
763 return std::string( 762 return std::string(
764 "Parallel FileIO::Read operations have written into wrong buffers."); 763 "Parallel FileIO::Read operations have written into wrong buffers.");
765 } 764 }
766 765
767 PASS(); 766 PASS();
768 } 767 }
769 768
770 std::string TestFileIO::TestParallelWrites() { 769 std::string TestFileIO::TestParallelWrites() {
771 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 770 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 rv = callback.WaitForResult(); 1090 rv = callback.WaitForResult();
1092 if ((invalid_combination && rv == PP_OK) || 1091 if ((invalid_combination && rv == PP_OK) ||
1093 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { 1092 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) {
1094 return ReportOpenError(open_flags); 1093 return ReportOpenError(open_flags);
1095 } 1094 }
1096 1095
1097 return std::string(); 1096 return std::string();
1098 } 1097 }
1099 1098
1100 // TODO(viettrungluu): Test Close(). crbug.com/69457 1099 // TODO(viettrungluu): Test Close(). crbug.com/69457
OLDNEW
« no previous file with comments | « ppapi/tests/test_audio_config.cc ('k') | ppapi/tests/test_flash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698