Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: chrome/browser/ui/autofill/country_combobox_model_unittest.cc

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..74f0fb7f324a9b212690a3a5259cd88dbd384f39
--- /dev/null
+++ b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc
@@ -0,0 +1,57 @@
+// 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/gmock/include/gmock/gmock.h"
+#include "testing/gmock_mutant.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace autofill {
+
+namespace {
+
+const char kTestCountry[] = "AQ";
+
+class MockObserver : public CountryComboboxModelObserver {
+ public:
+ MOCK_METHOD1(OnCountryComboboxModelChanged, void(CountryComboboxModel*));
+};
+
+} // namespace
+
+TEST(CountryComboboxModel, SelectCountryAndDefault) {
+ TestPersonalDataManager manager;
+ CountryComboboxModel model(manager);
+ EXPECT_TRUE(model.IsDefaultIndexSelected());
+
+ MockObserver observer;
+ model.AddCountryComboboxObserver(&observer);
+ EXPECT_CALL(observer, OnCountryComboboxModelChanged(&model)).Times(2);
+
+ const std::string default_country = model.GetSelectedCountryCode();
+ ASSERT_NE(default_country, kTestCountry);
+
+ model.SelectCountry(kTestCountry);
+ EXPECT_EQ(kTestCountry, model.GetSelectedCountryCode());
+ EXPECT_FALSE(model.IsDefaultIndexSelected());
+
+ // Selecting the default index should result in a selected index change.
+ model.SelectDefaultIndex();
+ EXPECT_EQ(default_country, model.GetSelectedCountryCode());
+ EXPECT_TRUE(model.IsDefaultIndexSelected());
+}
+
+TEST(CountryComboboxModel, RespectsManagersDefaultCountry) {
+ TestPersonalDataManager manager;
+ manager.set_timezone_country_code(kTestCountry);
+
+ CountryComboboxModel model(manager);
+ EXPECT_TRUE(model.IsDefaultIndexSelected());
+ EXPECT_EQ(kTestCountry, model.GetSelectedCountryCode());
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698