TEST(RuleGeneratorTest, testDensityRulesWithAnyDpi) {
    Vector<int> densities;
    const ssize_t highIndex = densities.add(ConfigDescription::DENSITY_HIGH);
    const ssize_t xhighIndex = densities.add(ConfigDescription::DENSITY_XHIGH);
    const ssize_t xxhighIndex = densities.add(ConfigDescription::DENSITY_XXHIGH);
    const ssize_t anyIndex = densities.add(ConfigDescription::DENSITY_ANY);

    EXPECT_RULES_EQ(RuleGenerator::generateDensity(densities, highIndex),
            AndRule()
            .add(LtRule(Rule::SDK_VERSION, SDK_LOLLIPOP))
            .add(LtRule(Rule::SCREEN_DENSITY, 263))
    );

    EXPECT_RULES_EQ(RuleGenerator::generateDensity(densities, xhighIndex),
            AndRule()
            .add(LtRule(Rule::SDK_VERSION, SDK_LOLLIPOP))
            .add(GtRule(Rule::SCREEN_DENSITY, 262))
            .add(LtRule(Rule::SCREEN_DENSITY, 363))
    );

    EXPECT_RULES_EQ(RuleGenerator::generateDensity(densities, xxhighIndex),
            AndRule()
            .add(LtRule(Rule::SDK_VERSION, SDK_LOLLIPOP))
            .add(GtRule(Rule::SCREEN_DENSITY, 362))
    );

    // We expect AlwaysTrue because anydpi always has attached v21 to the configuration
    // and the rest of the rule generation code generates the sdk version checks.
    EXPECT_RULES_EQ(RuleGenerator::generateDensity(densities, anyIndex), AlwaysTrue());
}
Exemplo n.º 2
0
Limit<Next> makeLimit(std::size_t maxHits, Next next = AlwaysTrue()) {
	return Limit<Next>(maxHits, next);
}