OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/base/data_buffer.h" |
| 6 #include "remoting/host/differ_block.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 |
| 9 namespace remoting { |
| 10 |
| 11 static const int kWidth = 32; |
| 12 static const int kHeight = 32; |
| 13 static const int kBytesPerPixel = 3; |
| 14 |
| 15 static void GenerateData(uint8* data, int size) { |
| 16 for (int i = 0; i < size; ++i) { |
| 17 data[i] = i; |
| 18 } |
| 19 } |
| 20 |
| 21 class EncodeDoneHandler |
| 22 : public base::RefCountedThreadSafe<EncodeDoneHandler> { |
| 23 public: |
| 24 MOCK_METHOD0(EncodeDone, void()); |
| 25 }; |
| 26 |
| 27 TEST(BlockDifferenceTest, BlockDifference) { |
| 28 // Prepare 2 blocks to compare. |
| 29 uint8 block1[kHeight * kWidth * kBytesPerPixel]; |
| 30 uint8 block2[kHeight * kWidth * kBytesPerPixel]; |
| 31 GenerateData(block1, sizeof(block1)); |
| 32 memcpy(block2, block1, sizeof(block2)); |
| 33 |
| 34 // These blocks should match. |
| 35 int same = BlockDifference(block1, block2, kWidth * kBytesPerPixel); |
| 36 EXPECT_EQ(0, same); |
| 37 |
| 38 // Change block2 a little. |
| 39 block2[7] += 3; |
| 40 block2[sizeof(block2)-1] -= 5; |
| 41 // These blocks should not match. The difference should be 8. |
| 42 int not_same = BlockDifference(block1, block2, kWidth * kBytesPerPixel); |
| 43 EXPECT_EQ(8, not_same); |
| 44 } |
| 45 |
| 46 } // namespace remoting |
OLD | NEW |