1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "third_party/libaddressinput/chromium/fallback_data_store.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/libaddressinput/src/cpp/src/util/json.h"
13 #include "third_party/libaddressinput/src/cpp/src/validating_util.h"
17 using i18n::addressinput::Json
;
18 using i18n::addressinput::ValidatingUtil
;
20 TEST(FallbackDataStore
, Parsability
) {
22 ASSERT_TRUE(FallbackDataStore::Get("data/US", &data
));
25 EXPECT_FALSE(ValidatingUtil::UnwrapTimestamp(&data
, time(NULL
)));
27 // Should be uncorrupted.
28 EXPECT_TRUE(ValidatingUtil::UnwrapChecksum(&data
));
30 // Should be valid JSON.
32 ASSERT_TRUE(json
.ParseObject(data
));
34 // Should have a dictionary for "data/US", as this is aggregate data.
35 std::string not_checked
;
36 EXPECT_FALSE(json
.GetStringValueForKey("data/US", ¬_checked
));
37 EXPECT_TRUE(json
.HasDictionaryValueForKey("data/US"));
40 } // namespace autofill