1// Copyright 2013 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.
4
5#include "components/autofill/core/browser/autofill_data_model.h"
6
7#include "base/compiler_specific.h"
8#include "testing/gtest/include/gtest/gtest.h"
9
10namespace autofill {
11
12namespace {
13
14// Provides concrete implementations for pure virtual methods.
15class TestAutofillDataModel : public AutofillDataModel {
16 public:
17  TestAutofillDataModel(const std::string& guid, const std::string& origin)
18      : AutofillDataModel(guid, origin) {}
19  virtual ~TestAutofillDataModel() {}
20
21 private:
22  virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE {
23    return base::string16();
24  }
25  virtual void SetRawInfo(ServerFieldType type,
26                          const base::string16& value) OVERRIDE {}
27  virtual void GetSupportedTypes(
28      ServerFieldTypeSet* supported_types) const OVERRIDE {}
29
30  DISALLOW_COPY_AND_ASSIGN(TestAutofillDataModel);
31};
32
33}  // namespace
34
35TEST(AutofillDataModelTest, IsVerified) {
36  TestAutofillDataModel model("guid", std::string());
37  EXPECT_FALSE(model.IsVerified());
38
39  model.set_origin("http://www.example.com");
40  EXPECT_FALSE(model.IsVerified());
41
42  model.set_origin("https://www.example.com");
43  EXPECT_FALSE(model.IsVerified());
44
45  model.set_origin("file:///tmp/example.txt");
46  EXPECT_FALSE(model.IsVerified());
47
48  model.set_origin("data:text/plain;charset=utf-8;base64,ZXhhbXBsZQ==");
49  EXPECT_FALSE(model.IsVerified());
50
51  model.set_origin("chrome://settings/autofill");
52  EXPECT_FALSE(model.IsVerified());
53
54  model.set_origin("Chrome Settings");
55  EXPECT_TRUE(model.IsVerified());
56
57  model.set_origin("Some gibberish string");
58  EXPECT_TRUE(model.IsVerified());
59
60  model.set_origin(std::string());
61  EXPECT_FALSE(model.IsVerified());
62}
63
64}  // namespace autofill
65