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