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