| Index: chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
|
| diff --git a/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc b/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
|
| index 2a2585cab702006e1e3b2fa0e1b133bcdc251269..ffe14f05f882d0e2f44eb1347cf95e6ef63780f7 100644
|
| --- a/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
|
| +++ b/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
|
| @@ -14,65 +14,36 @@ class TestLoginUI : public LoginUIService::LoginUI {
|
| TestLoginUI() { }
|
| ~TestLoginUI() override {}
|
| void FocusUI() override {}
|
| - void CloseUI() override {}
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(TestLoginUI);
|
| };
|
|
|
| -class TestObserver : public LoginUIService::Observer {
|
| - public:
|
| - TestObserver() : ui_shown_count_(0),
|
| - ui_closed_count_(0) {
|
| - }
|
| -
|
| - int ui_shown_count() const { return ui_shown_count_; }
|
| - int ui_closed_count() const { return ui_closed_count_; }
|
| -
|
| - private:
|
| - void OnLoginUIShown(LoginUIService::LoginUI* ui) override {
|
| - ++ui_shown_count_;
|
| - }
|
| +TEST(LoginUIServiceTest, CanSetMultipleLoginUIs) {
|
| + LoginUIService service(nullptr);
|
|
|
| - void OnLoginUIClosed(LoginUIService::LoginUI* ui) override {
|
| - ++ui_closed_count_;
|
| - }
|
| -
|
| - int ui_shown_count_;
|
| - int ui_closed_count_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(TestObserver);
|
| -};
|
| + EXPECT_EQ(nullptr, service.current_login_ui());
|
|
|
| -class LoginUIServiceTest : public testing::Test {
|
| - public:
|
| - LoginUIServiceTest() : service_(NULL) { }
|
| - ~LoginUIServiceTest() override {}
|
| -
|
| - protected:
|
| - LoginUIService service_;
|
| - TestObserver observer_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(LoginUIServiceTest);
|
| -};
|
| -
|
| -// Test that the observer is called back when login UI is shown
|
| -// or closed.
|
| -TEST_F(LoginUIServiceTest, LoginUIServiceObserver) {
|
| - service_.AddObserver(&observer_);
|
| - EXPECT_EQ(NULL, service_.current_login_ui());
|
| TestLoginUI ui;
|
| - service_.SetLoginUI(&ui);
|
| - EXPECT_EQ(1, observer_.ui_shown_count());
|
| + service.SetLoginUI(&ui);
|
| + EXPECT_EQ(&ui, service.current_login_ui());
|
|
|
| - // If a different UI is closed than the one that was shown, no
|
| - // notification should be fired.
|
| + // Test that we can replace the active login UI.
|
| TestLoginUI other_ui;
|
| - service_.LoginUIClosed(&other_ui);
|
| - EXPECT_EQ(1, observer_.ui_shown_count());
|
| -
|
| - // If the right UI is closed, notification should be fired.
|
| - service_.LoginUIClosed(&ui);
|
| - EXPECT_EQ(1, observer_.ui_closed_count());
|
| - service_.RemoveObserver(&observer_);
|
| + service.SetLoginUI(&other_ui);
|
| + EXPECT_EQ(&other_ui, service.current_login_ui());
|
| +
|
| + // Test that closing the non-active login UI has no effect.
|
| + service.LoginUIClosed(&ui);
|
| + EXPECT_EQ(&other_ui, service.current_login_ui());
|
| +
|
| + // Test that closing the foreground UI yields the background UI.
|
| + service.SetLoginUI(&ui);
|
| + EXPECT_EQ(&ui, service.current_login_ui());
|
| + service.LoginUIClosed(&ui);
|
| + EXPECT_EQ(&other_ui, service.current_login_ui());
|
| +
|
| + // Test that closing the last login UI makes the current login UI nullptr.
|
| + service.LoginUIClosed(&other_ui);
|
| + EXPECT_EQ(nullptr, service.current_login_ui());
|
| }
|
|
|