Index: chrome/browser/ui/autofill/country_combobox_model_unittest.cc |
diff --git a/chrome/browser/ui/autofill/country_combobox_model_unittest.cc b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..347833b37a612a639d63f5ad22d8b41edf65af2a |
--- /dev/null |
+++ b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc |
@@ -0,0 +1,48 @@ |
+// 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 "chrome/browser/ui/autofill/country_combobox_model.h" |
+ |
+#include "components/autofill/core/browser/autofill_country.h" |
+#include "components/autofill/core/browser/test_personal_data_manager.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace autofill { |
+ |
+TEST(CountryComboboxModel, SelectIndexes) { |
+ TestPersonalDataManager manager; |
+ CountryComboboxModel model(manager); |
+ EXPECT_TRUE(model.IsDefaultIndexSelected()); |
+ |
+ const std::string default_country = model.GetSelectedCountryCode(); |
+ |
+ model.SelectIndex(5); |
+ EXPECT_NE(default_country, model.GetSelectedCountryCode()); |
+ EXPECT_FALSE(model.IsDefaultIndexSelected()); |
+ |
+ model.SelectDefaultIndex(); |
+ EXPECT_EQ(default_country, model.GetSelectedCountryCode()); |
+ EXPECT_TRUE(model.IsDefaultIndexSelected()); |
+} |
+ |
+TEST(CountryComboboxModel, SelectCountry) { |
+ TestPersonalDataManager manager; |
+ CountryComboboxModel model(manager); |
+ |
+ EXPECT_NE("AQ", model.GetSelectedCountryCode()); |
+ model.SelectCountry("AQ"); |
+ EXPECT_EQ("AQ", model.GetSelectedCountryCode()); |
+} |
+ |
+TEST(CountryComboboxModel, DefaultCountry) { |
+ TestPersonalDataManager manager; |
+ ASSERT_NE("AQ", manager.GetDefaultCountryCodeForNewAddress()); |
+ manager.set_default_country_code("AQ"); |
+ |
+ CountryComboboxModel model(manager); |
+ EXPECT_EQ("AQ", model.countries()[model.GetDefaultIndex()]->country_code()); |
+ EXPECT_EQ("AQ", model.GetSelectedCountryCode()); |
+} |
+ |
+} // namespace autofill |