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

Unified Diff: chrome/browser/ui/webui/signin/login_ui_service_unittest.cc

Issue 1984863002: Clean up LoginUIService. Remove Singleton behavior from PeopleHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge issue Created 4 years, 6 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/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());
}
« no previous file with comments | « chrome/browser/ui/webui/signin/login_ui_service.cc ('k') | components/browser_sync/browser/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698