blob: f66de0518f80e4efd627d7720d2268e632dbef72 [file] [log] [blame]
Chenjie Yu6b1667c2019-01-18 10:09:33 -08001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include <gmock/gmock.h>
16#include <gtest/gtest.h>
17#include <stdio.h>
18#include "src/storage/StorageManager.h"
19
20#ifdef __ANDROID__
21
22namespace android {
23namespace os {
24namespace statsd {
25
26using namespace testing;
27using std::make_shared;
28using std::shared_ptr;
29using std::vector;
30using testing::Contains;
31
32TEST(StorageManagerTest, TrainInfoReadWriteTest) {
Chenjie Yu97dbb202019-02-13 16:42:04 -080033 InstallTrainInfo trainInfo;
Chenjie Yu6b1667c2019-01-18 10:09:33 -080034 trainInfo.trainVersionCode = 12345;
35 const char* expIds = "test_ids";
36 trainInfo.experimentIds.assign(expIds, expIds + strlen(expIds));
37
38 StorageManager::writeTrainInfo(trainInfo.trainVersionCode, trainInfo.experimentIds);
39
Chenjie Yu97dbb202019-02-13 16:42:04 -080040 InstallTrainInfo result;
Chenjie Yu6b1667c2019-01-18 10:09:33 -080041 StorageManager::readTrainInfo(result);
42 EXPECT_EQ(trainInfo.trainVersionCode, result.trainVersionCode);
43 EXPECT_EQ(trainInfo.experimentIds.size(), result.experimentIds.size());
44 EXPECT_EQ(trainInfo.experimentIds, result.experimentIds);
45}
46
47} // namespace statsd
48} // namespace os
49} // namespace android
50#else
51GTEST_LOG_(INFO) << "This test does nothing.\n";
52#endif