Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_data_model_unittest.cc
blobdec20271d629e262b4224281028d7e372f3a1999
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.
5 #include "components/autofill/core/browser/autofill_data_model.h"
7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace autofill {
12 namespace {
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 {}
21 private:
22 base::string16 GetRawInfo(ServerFieldType type) const override {
23 return base::string16();
25 void SetRawInfo(ServerFieldType type, const base::string16& value) override {}
26 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override {}
28 DISALLOW_COPY_AND_ASSIGN(TestAutofillDataModel);
31 } // namespace
33 TEST(AutofillDataModelTest, IsVerified) {
34 TestAutofillDataModel model("guid", std::string());
35 EXPECT_FALSE(model.IsVerified());
37 model.set_origin("http://www.example.com");
38 EXPECT_FALSE(model.IsVerified());
40 model.set_origin("https://www.example.com");
41 EXPECT_FALSE(model.IsVerified());
43 model.set_origin("file:///tmp/example.txt");
44 EXPECT_FALSE(model.IsVerified());
46 model.set_origin("data:text/plain;charset=utf-8;base64,ZXhhbXBsZQ==");
47 EXPECT_FALSE(model.IsVerified());
49 model.set_origin("chrome://settings/autofill");
50 EXPECT_FALSE(model.IsVerified());
52 model.set_origin("Chrome Settings");
53 EXPECT_TRUE(model.IsVerified());
55 model.set_origin("Some gibberish string");
56 EXPECT_TRUE(model.IsVerified());
58 model.set_origin(std::string());
59 EXPECT_FALSE(model.IsVerified());
62 } // namespace autofill