| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "tests/common/win/testing_common.h" | 35 #include "tests/common/win/testing_common.h" |
| 36 #include "tests/common/cross/test_utils.h" | 36 #include "tests/common/cross/test_utils.h" |
| 37 | 37 |
| 38 namespace o3d { | 38 namespace o3d { |
| 39 | 39 |
| 40 class TarProcessorTest : public testing::Test { | 40 class TarProcessorTest : public testing::Test { |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // We verify that the tar file contains exactly these filenames | 43 // We verify that the tar file contains exactly these filenames |
| 44 static const char *kFilename1 = "test/file1"; | 44 static const char *kFilename1 = "test/file1"; |
| 45 static const char *kFilename2 = "test/file2"; | 45 static const char *kFilename2 = |
| 46 static const char *kFilename3 = "test/file3"; | 46 "test/file1ThisIsAFilenameLongerThen100Chars" |
| 47 "ThisIsAFilenameLongerThen100Chars" |
| 48 "ThisIsAFilenameLongerThen100CharsThisIsAFilenameLongerThen100Chars"; |
| 49 static const char *kFilename3 = "test/file2"; |
| 50 static const char *kFilename4 = "test/file3"; |
| 47 | 51 |
| 48 // With each file having these exact contents | 52 // With each file having these exact contents |
| 49 #define kFileContents1 "the cat in the hat\n" | |
| 50 #define kFileContents2 "abracadabra\n" | |
| 51 #define kFileContents3 "I think therefore I am\n" | |
| 52 | 53 |
| 53 // we should receive these (and exactly these bytes in this order) | 54 // we should receive these (and exactly these bytes in this order) |
| 54 static const char *kConcatenatedContents = | 55 static const char *kConcatenatedContents = |
| 55 kFileContents1 kFileContents2 kFileContents3; | 56 "the cat in the hat\n" // file 1 contents. |
| 57 "this file has a long name" // file 2 contents. |
| 58 "abracadabra\n" // file 3 contents. |
| 59 "I think therefore I am\n" // file 4 contents. |
| 60 ""; // end |
| 56 | 61 |
| 57 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 62 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 58 class TarTestClient : public ArchiveCallbackClient { | 63 class TarTestClient : public ArchiveCallbackClient { |
| 59 public: | 64 public: |
| 60 explicit TarTestClient() : file_count_(0), index_(0) {} | 65 explicit TarTestClient() : file_count_(0), index_(0) {} |
| 61 // ArchiveCallbackClient methods | 66 // ArchiveCallbackClient methods |
| 62 virtual void ReceiveFileHeader(const ArchiveFileInfo &file_info); | 67 virtual void ReceiveFileHeader(const ArchiveFileInfo &file_info); |
| 63 virtual bool ReceiveFileData(MemoryReadStream *stream, size_t nbytes); | 68 virtual bool ReceiveFileData(MemoryReadStream *stream, size_t nbytes); |
| 64 | 69 |
| 65 int GetFileCount() const { return file_count_; } | 70 int GetFileCount() const { return file_count_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 switch (file_count_) { | 83 switch (file_count_) { |
| 79 case 0: | 84 case 0: |
| 80 EXPECT_TRUE(!strcmp(kFilename1, file_info.GetFileName().c_str())); | 85 EXPECT_TRUE(!strcmp(kFilename1, file_info.GetFileName().c_str())); |
| 81 break; | 86 break; |
| 82 case 1: | 87 case 1: |
| 83 EXPECT_TRUE(!strcmp(kFilename2, file_info.GetFileName().c_str())); | 88 EXPECT_TRUE(!strcmp(kFilename2, file_info.GetFileName().c_str())); |
| 84 break; | 89 break; |
| 85 case 2: | 90 case 2: |
| 86 EXPECT_TRUE(!strcmp(kFilename3, file_info.GetFileName().c_str())); | 91 EXPECT_TRUE(!strcmp(kFilename3, file_info.GetFileName().c_str())); |
| 87 break; | 92 break; |
| 93 case 3: |
| 94 EXPECT_TRUE(!strcmp(kFilename4, file_info.GetFileName().c_str())); |
| 95 break; |
| 88 } | 96 } |
| 89 | 97 |
| 90 file_count_++; | 98 file_count_++; |
| 91 } | 99 } |
| 92 | 100 |
| 93 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 101 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 94 bool TarTestClient::ReceiveFileData(MemoryReadStream *stream, size_t nbytes) { | 102 bool TarTestClient::ReceiveFileData(MemoryReadStream *stream, size_t nbytes) { |
| 95 const char *p = reinterpret_cast<const char*>( | 103 const char *p = reinterpret_cast<const char*>( |
| 96 stream->GetDirectMemoryPointer()); | 104 stream->GetDirectMemoryPointer()); |
| 97 | 105 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 result = tar_processor.ProcessBytes(&tar_stream, bytes_this_time); | 150 result = tar_processor.ProcessBytes(&tar_stream, bytes_this_time); |
| 143 EXPECT_TRUE(result == Z_OK); | 151 EXPECT_TRUE(result == Z_OK); |
| 144 | 152 |
| 145 bytes_to_process -= bytes_this_time; | 153 bytes_to_process -= bytes_this_time; |
| 146 } | 154 } |
| 147 | 155 |
| 148 free(tar_data); | 156 free(tar_data); |
| 149 } | 157 } |
| 150 | 158 |
| 151 } // namespace | 159 } // namespace |
| OLD | NEW |