Merge "This cl tries to fix cts tests IncidentdTest" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-05 18:48:59 +00:00
committed by Android (Google) Code Review
8 changed files with 80 additions and 10 deletions

View File

@@ -34,7 +34,7 @@ namespace incidentd {
void PrivacyBuffer::writeFieldOrSkip(uint32_t fieldTag, bool skip) {
uint8_t wireType = read_wire_type(fieldTag);
size_t bytesToWrite = 0;
uint32_t varint = 0;
uint64_t varint = 0;
switch (wireType) {
case WIRE_TYPE_VARINT:

View File

@@ -31,7 +31,7 @@ namespace android {
namespace os {
namespace incidentd {
const int64_t REMOTE_CALL_TIMEOUT_MS = 10 * 1000; // 10 seconds
const int64_t REMOTE_CALL_TIMEOUT_MS = 30 * 1000; // 30 seconds
/**
* Base class for sections

View File

@@ -170,7 +170,7 @@ message IncidentProto {
];
optional BatteryTypeProto battery_type = 2006 [
(section).type = SECTION_FILE,
(section).type = SECTION_NONE, // disabled since the path is device specific!
(section).args = "/sys/class/power_supply/bms/battery_type"
];

View File

@@ -65,7 +65,7 @@ message NotificationRecordProto {
optional bool can_vibrate = 7;
optional bool can_show_light = 8;
optional string group_key = 9 [ (.android.privacy).dest = DEST_EXPLICIT ];
optional int32 importance = 10;
optional sint32 importance = 10;
}
message ListenersDisablingEffectsProto {
@@ -122,11 +122,11 @@ message RankingHelperProto {
// Default value is UNKNOWN_UID = USER_NULL = -10000.
optional int32 uid = 2;
// Default is IMPORTANCE_UNSPECIFIED (-1000).
optional int32 importance = 3;
optional sint32 importance = 3;
// Default is PRIORITY_DEFAULT (0).
optional int32 priority = 4;
// Default is VISIBILITY_NO_OVERRIDE (-1000).
optional int32 visibility = 5;
optional sint32 visibility = 5;
// Default is true.
optional bool show_badge = 6;
repeated android.app.NotificationChannelProto channels = 7;

View File

@@ -37,3 +37,20 @@ cc_library {
"liblog",
],
}
cc_test {
name: "libprotoutil_test",
srcs: [
"tests/EncodedBuffer_test.cpp",
],
shared_libs: [
"libcutils",
"libprotoutil",
],
static_libs: [
"libgmock",
],
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration description="Config for libprotoutil_test">
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
<option name="push" value="libprotoutil_test->/data/nativetest/libprotoutil_test" />
</target_preparer>
<option name="test-suite-tag" value="apct" />
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/nativetest" />
<option name="module-name" value="libprotoutil_test" />
</test>
</configuration>

View File

@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "libprotoutil"
#include <stdlib.h>
#include <android/util/EncodedBuffer.h>
#include <android/util/protobuf.h>
#include <stdlib.h>
#include <cutils/log.h>
namespace android {
namespace util {
@@ -228,7 +230,7 @@ EncodedBuffer::readRawVarint()
size_t start = mEp.pos();
while (true) {
uint8_t byte = readRawByte();
val += (byte & 0x7F) << shift;
val |= (UINT64_C(0x7F) & byte) << shift;
if ((byte & 0x80) == 0) break;
shift += 7;
}
@@ -345,7 +347,7 @@ EncodedBuffer::iterator::readRawVarint()
uint64_t val = 0, shift = 0;
while (true) {
uint8_t byte = next();
val += (byte & 0x7F) << shift;
val |= (INT64_C(0x7F) & byte) << shift;
if ((byte & 0x80) == 0) break;
shift += 7;
}

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <android/util/EncodedBuffer.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using namespace android::util;
TEST(EncodedBufferTest, ReadVarint) {
EncodedBuffer buffer;
uint64_t val = UINT64_C(1522865904593);
buffer.writeRawVarint64(val);
EXPECT_EQ(val, buffer.begin().readRawVarint());
}