This source file includes following definitions.
- TEST
#include "chrome/common/metrics/caching_permuted_entropy_provider.h"
#include <string>
#include "base/basictypes.h"
#include "base/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics {
const size_t kMaxLowEntropySize = 8000;
const char* const kTestTrialNames[] = { "TestTrial", "AnotherTestTrial",
"NewTabButton" };
TEST(CachingPermutedEntropyProviderTest, HasConsistentResults) {
TestingPrefServiceSimple prefs;
CachingPermutedEntropyProvider::RegisterPrefs(prefs.registry());
const int kEntropyValue = 1234;
PermutedEntropyProvider provider(kEntropyValue, kMaxLowEntropySize);
for (size_t i = 0; i < 2 * arraysize(kTestTrialNames); ++i) {
CachingPermutedEntropyProvider cached_provider(&prefs, kEntropyValue,
kMaxLowEntropySize);
const std::string trial_name =
kTestTrialNames[i % arraysize(kTestTrialNames)];
EXPECT_DOUBLE_EQ(provider.GetEntropyForTrial(trial_name, 0),
cached_provider.GetEntropyForTrial(trial_name, 0));
}
CachingPermutedEntropyProvider cached_provider(&prefs, kEntropyValue,
kMaxLowEntropySize);
for (size_t i = 0; i < 2 * arraysize(kTestTrialNames); ++i) {
const std::string trial_name =
kTestTrialNames[i % arraysize(kTestTrialNames)];
EXPECT_DOUBLE_EQ(provider.GetEntropyForTrial(trial_name, 0),
cached_provider.GetEntropyForTrial(trial_name, 0));
}
}
}