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

Unified Diff: third_party/libaddressinput/chromium/fallback_data_store_unittest.cc

Issue 389733002: Reland "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix GN build. Created 6 years, 5 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
Index: third_party/libaddressinput/chromium/fallback_data_store_unittest.cc
diff --git a/third_party/libaddressinput/chromium/fallback_data_store_unittest.cc b/third_party/libaddressinput/chromium/fallback_data_store_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31f32b17c95a5b194ff3e0e7e6cf54d80085dfd6
--- /dev/null
+++ b/third_party/libaddressinput/chromium/fallback_data_store_unittest.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/libaddressinput/chromium/fallback_data_store.h"
+
+#include <cstddef>
+#include <ctime>
+#include <string>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/libaddressinput/src/cpp/src/util/json.h"
+#include "third_party/libaddressinput/src/cpp/src/validating_util.h"
+
+namespace autofill {
+
+using i18n::addressinput::Json;
+using i18n::addressinput::ValidatingUtil;
+
+TEST(FallbackDataStore, Parsability) {
+ std::string data;
+ ASSERT_TRUE(FallbackDataStore::Get("data/US", &data));
+
+ // Should be stale.
+ EXPECT_FALSE(ValidatingUtil::UnwrapTimestamp(&data, time(NULL)));
+
+ // Should be uncorrupted.
+ EXPECT_TRUE(ValidatingUtil::UnwrapChecksum(&data));
+
+ // Should be valid JSON.
+ Json json;
+ ASSERT_TRUE(json.ParseObject(data));
+
+ // Should have a dictionary for "data/US", as this is aggregate data.
+ std::string not_checked;
+ EXPECT_FALSE(json.GetStringValueForKey("data/US", &not_checked));
+ EXPECT_TRUE(json.HasDictionaryValueForKey("data/US"));
+}
+
+} // namespace autofill
« no previous file with comments | « third_party/libaddressinput/chromium/fallback_data_store.cc ('k') | third_party/libaddressinput/chromium/input_suggester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698