Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: components/policy/core/common/preg_parser_unittest.cc

Issue 2860973002: Allow PolicyLoadStatusSample to override reporting method (Closed)
Patch Set: Cleanups and class rename. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/preg_parser_fuzzer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/preg_parser_unittest.cc
diff --git a/components/policy/core/common/preg_parser_unittest.cc b/components/policy/core/common/preg_parser_unittest.cc
index d45a57bd7d13ea1f1d3cec9fda597830b3cca091..e4716a16ff56cf0ac703b4c8f09b3c1d82cc3061 100644
--- a/components/policy/core/common/preg_parser_unittest.cc
+++ b/components/policy/core/common/preg_parser_unittest.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/base_paths.h"
+#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
@@ -26,6 +27,7 @@ namespace {
const char kRegistryPolBaseDir[] = "chrome/test/data/policy/gpo";
const char kRegistryPolFile[] = "parser_test/registry.pol";
const char kInvalidEncodingRegistryPolFile[] = "invalid_encoding/registry.pol";
+const char kNonExistingRegistryPolFile[] = "does_not_exist.pol";
const char kRegistryKey[] = "SOFTWARE\\Policies\\Chromium";
@@ -116,7 +118,7 @@ TEST_F(PRegParserTest, TestParseFile) {
// Run the parser.
base::FilePath test_file(test_data_dir_.AppendASCII(kRegistryPolFile));
- PolicyLoadStatusSample status;
+ PolicyLoadStatusUmaReporter status;
ASSERT_TRUE(preg_parser::ReadFile(test_file, base::ASCIIToUTF16(kRegistryKey),
&dict, &status));
@@ -144,7 +146,7 @@ TEST_F(PRegParserTest, SubstringRootInvalid) {
// key like "Aa/Bb/C".
base::FilePath test_file(test_data_dir_.AppendASCII(kRegistryPolFile));
RegistryDict empty;
- PolicyLoadStatusSample status;
+ PolicyLoadStatusUmaReporter status;
// No data should be loaded for partial roots ("Aa/Bb/C").
RegistryDict dict1;
@@ -164,7 +166,7 @@ TEST_F(PRegParserTest, RejectInvalidStrings) {
// Tests whether strings with invalid characters are rejected.
base::FilePath test_file(
test_data_dir_.AppendASCII(kInvalidEncodingRegistryPolFile));
- PolicyLoadStatusSample status;
+ PolicyLoadStatusUmaReporter status;
RegistryDict dict;
ASSERT_TRUE(preg_parser::ReadFile(test_file, base::ASCIIToUTF16(kRegistryKey),
&dict, &status));
@@ -173,6 +175,21 @@ TEST_F(PRegParserTest, RejectInvalidStrings) {
EXPECT_TRUE(RegistryDictEquals(dict, empty));
}
+TEST_F(PRegParserTest, LoadStatusSampling) {
+ // Tests load status sampling.
+ PolicyLoadStatusUmaReporter status;
+ RegistryDict dict;
+ base::FilePath test_file(
+ test_data_dir_.AppendASCII(kNonExistingRegistryPolFile));
+ ASSERT_FALSE(preg_parser::ReadFile(
+ test_file, base::ASCIIToUTF16(kRegistryKey), &dict, &status));
+
+ PolicyLoadStatusSampler::StatusSet expected_status_set;
+ expected_status_set[POLICY_LOAD_STATUS_STARTED] = true;
+ expected_status_set[POLICY_LOAD_STATUS_READ_ERROR] = true;
+ EXPECT_EQ(expected_status_set, status.GetStatusSet());
+}
+
} // namespace
} // namespace preg_parser
} // namespace policy
« no previous file with comments | « components/policy/core/common/preg_parser_fuzzer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698