Commit 0b6e6a5a authored by Yue Cen's avatar Yue Cen Committed by Commit Bot

Retrieve Play Store version from features JSON.

Bug: 835029
Change-Id: Ia50091e2e1669f180f4d9eb5860a59a141bc0c4c
Reviewed-on: https://chromium-review.googlesource.com/1150636Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Commit-Queue: Yue Cen <rsgingerrs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579885}
parent 07d9675f
......@@ -95,6 +95,15 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
arc_features.build_props.emplace(item.first, item.second.GetString());
}
// Parse the Play Store version
const base::Value* play_version = json_value->FindKeyOfType(
"play_store_version", base::Value::Type::STRING);
if (!play_version) {
LOG(ERROR) << "No Play Store version in JSON.";
return base::nullopt;
}
arc_features.play_store_version = play_version->GetString();
return arc_features;
}
......
......@@ -46,6 +46,8 @@ struct ArcFeatures {
// This map contains all ARC build properties.
BuildPropsMapping build_props;
std::string play_store_version;
private:
DISALLOW_COPY_AND_ASSIGN(ArcFeatures);
};
......@@ -71,7 +73,8 @@ struct ArcFeatures {
// "properties": {
// "ro.product.cpu.abilist": "x86_64,x86,armeabi-v7a,armeabi",
// "ro.build.version.sdk": "25"
// }
// },
// "play_store_version": "81010860"
// }
class ArcFeaturesParser {
public:
......
......@@ -31,7 +31,8 @@ constexpr const char kValidJson[] = R"json({"features": [
"properties": {
"ro.product.cpu.abilist": "x86_64,x86,armeabi-v7a,armeabi",
"ro.build.version.sdk": "25"
}})json";
},
"play_store_version": "81010860"})json";
constexpr const char kValidJsonWithUnavailableFeature[] =
R"json({"features": [
......@@ -45,7 +46,8 @@ constexpr const char kValidJsonWithUnavailableFeature[] =
}
],
"unavailable_features": ["android.software.location"],
"properties": {}})json";
"properties": {},
"play_store_version": "81010860"})json";
constexpr const char kValidJsonFeatureEmptyName[] =
R"json({"features": [
......@@ -63,9 +65,10 @@ constexpr const char kValidJsonFeatureEmptyName[] =
}
],
"unavailable_features": ["android.software.home_screen", ""],
"properties": {}})json";
"properties": {},
"play_store_version": "81010860"})json";
constexpr const char kValidJsonWithMissingFields[] =
constexpr const char kInvalidJsonWithMissingFields[] =
R"json({"invalid_root": [
{
"name": "android.hardware.location"
......@@ -86,7 +89,7 @@ TEST_F(ArcFeaturesParserTest, ParseEmptyJson) {
TEST_F(ArcFeaturesParserTest, ParseInvalidJson) {
base::Optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(
kValidJsonWithMissingFields);
kInvalidJsonWithMissingFields);
EXPECT_EQ(arc_features, base::nullopt);
}
......@@ -96,9 +99,11 @@ TEST_F(ArcFeaturesParserTest, ParseValidJson) {
auto feature_map = arc_features->feature_map;
auto unavailable_features = arc_features->unavailable_features;
auto build_props = arc_features->build_props;
auto play_store_version = arc_features->play_store_version;
EXPECT_EQ(feature_map.size(), 2u);
EXPECT_EQ(unavailable_features.size(), 0u);
EXPECT_EQ(build_props.size(), 2u);
EXPECT_EQ(play_store_version, "81010860");
}
TEST_F(ArcFeaturesParserTest, ParseValidJsonWithUnavailableFeature) {
......@@ -108,9 +113,11 @@ TEST_F(ArcFeaturesParserTest, ParseValidJsonWithUnavailableFeature) {
auto feature_map = arc_features->feature_map;
auto unavailable_features = arc_features->unavailable_features;
auto build_props = arc_features->build_props;
auto play_store_version = arc_features->play_store_version;
EXPECT_EQ(feature_map.size(), 2u);
EXPECT_EQ(unavailable_features.size(), 1u);
EXPECT_EQ(build_props.size(), 0u);
EXPECT_EQ(play_store_version, "81010860");
}
TEST_F(ArcFeaturesParserTest, ParseValidJsonWithEmptyFeatureName) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment