summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Joe Onorato <joeo@google.com> 2019-03-27 00:20:25 -0700
committer Joe Onorato <joeo@google.com> 2019-03-27 00:23:20 -0700
commitceece4851870405fb75dc915f2293a985bd3a294 (patch)
treec277cbe1b3fe7cca0ca6c9c43f1a482da1f0ff92
parentad8e2b77bde4b57bc0f431f8f92a284c6dd17d02 (diff)
Fix the build
Change-Id: I770ed6fd8de0479655f587db68a09882eb6cceb5
-rw-r--r--libs/protoutil/tests/EncodedBuffer_test.cpp32
-rw-r--r--libs/protoutil/tests/ProtoOutputStream_test.cpp10
2 files changed, 19 insertions, 23 deletions
diff --git a/libs/protoutil/tests/EncodedBuffer_test.cpp b/libs/protoutil/tests/EncodedBuffer_test.cpp
index 964fc8ec9ee0..398af609c083 100644
--- a/libs/protoutil/tests/EncodedBuffer_test.cpp
+++ b/libs/protoutil/tests/EncodedBuffer_test.cpp
@@ -16,6 +16,7 @@
#include <gtest/gtest.h>
using namespace android::util;
+using android::sp;
constexpr size_t TEST_CHUNK_SIZE = 16UL;
constexpr size_t TEST_CHUNK_HALF_SIZE = TEST_CHUNK_SIZE / 2;
@@ -122,33 +123,30 @@ TEST(EncodedBufferTest, ReadSimple) {
for (size_t i = 0; i < TEST_CHUNK_3X_SIZE; i++) {
buffer.writeRawByte(i);
}
- auto iter = buffer.begin();
- EXPECT_EQ(iter.size(), TEST_CHUNK_3X_SIZE);
- EXPECT_EQ(iter.bytesRead(), 0);
+ sp<ProtoReader> reader1 = buffer.read();
+ EXPECT_EQ(reader1->size(), TEST_CHUNK_3X_SIZE);
+ EXPECT_EQ(reader1->bytesRead(), 0);
- expectPointer(iter.rp(), 0);
- while (iter.readBuffer() != NULL) {
- iter.rp()->move(iter.currentToRead());
+ while (reader1->readBuffer() != NULL) {
+ reader1->move(reader1->currentToRead());
}
- EXPECT_EQ(iter.bytesRead(), TEST_CHUNK_3X_SIZE);
- expectPointer(iter.rp(), TEST_CHUNK_3X_SIZE);
+ EXPECT_EQ(reader1->bytesRead(), TEST_CHUNK_3X_SIZE);
- iter.rp()->rewind();
- expectPointer(iter.rp(), 0);
+ sp<ProtoReader> reader2 = buffer.read();
uint8_t val = 0;
- while (iter.hasNext()) {
- EXPECT_EQ(iter.next(), val);
+ while (reader2->hasNext()) {
+ EXPECT_EQ(reader2->next(), val);
val++;
}
- EXPECT_EQ(iter.bytesRead(), TEST_CHUNK_3X_SIZE);
- expectPointer(iter.rp(), TEST_CHUNK_3X_SIZE);
+ EXPECT_EQ(reader2->bytesRead(), TEST_CHUNK_3X_SIZE);
+ EXPECT_EQ(reader1->bytesRead(), TEST_CHUNK_3X_SIZE);
}
TEST(EncodedBufferTest, ReadVarint) {
EncodedBuffer buffer;
uint64_t val = UINT64_C(1522865904593);
size_t len = buffer.writeRawVarint64(val);
- auto iter = buffer.begin();
- EXPECT_EQ(iter.size(), len);
- EXPECT_EQ(iter.readRawVarint(), val);
+ sp<ProtoReader> reader = buffer.read();
+ EXPECT_EQ(reader->size(), len);
+ EXPECT_EQ(reader->readRawVarint(), val);
}
diff --git a/libs/protoutil/tests/ProtoOutputStream_test.cpp b/libs/protoutil/tests/ProtoOutputStream_test.cpp
index 27ee13d4dfe1..9d357f3c3363 100644
--- a/libs/protoutil/tests/ProtoOutputStream_test.cpp
+++ b/libs/protoutil/tests/ProtoOutputStream_test.cpp
@@ -21,6 +21,7 @@
#include "frameworks/base/libs/protoutil/tests/test.pb.h"
+using android::sp;
using namespace android::base;
using namespace android::util;
using ::testing::StrEq;
@@ -38,9 +39,9 @@ static std::string flushToString(ProtoOutputStream* proto) {
static std::string iterateToString(ProtoOutputStream* proto) {
std::string content;
content.reserve(proto->size());
- auto iter = proto->data();
- while (iter.hasNext()) {
- content.push_back(iter.next());
+ sp<ProtoReader> reader = proto->data();
+ while (reader->hasNext()) {
+ content.push_back(reader->next());
}
return content;
}
@@ -198,7 +199,6 @@ TEST(ProtoOutputStreamTest, NoEndCalled) {
// no proto.end called
EXPECT_NE(proto.bytesWritten(), 0);
EXPECT_EQ(proto.size(), 0);
- EXPECT_EQ(proto.data().size(), 0);
EXPECT_FALSE(proto.flush(STDOUT_FILENO));
}
@@ -211,7 +211,6 @@ TEST(ProtoOutputStreamTest, TwoEndCalled) {
proto.end(token);
EXPECT_NE(proto.bytesWritten(), 0);
EXPECT_EQ(proto.size(), 0);
- EXPECT_EQ(proto.data().size(), 0);
EXPECT_FALSE(proto.flush(STDOUT_FILENO));
}
@@ -223,6 +222,5 @@ TEST(ProtoOutputStreamTest, NoStartCalled) {
proto.end(wrongToken);
EXPECT_NE(proto.bytesWritten(), 0);
EXPECT_EQ(proto.size(), 0);
- EXPECT_EQ(proto.data().size(), 0);
EXPECT_FALSE(proto.flush(STDOUT_FILENO));
}