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

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

Issue 10699013: Add a method to LoginUIService to open the sign in UI in a popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
===================================================================
--- chrome/browser/ui/webui/signin/login_ui_service_unittest.cc (revision 0)
+++ chrome/browser/ui/webui/signin/login_ui_service_unittest.cc (revision 0)
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 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/webui/signin/login_ui_service.h"
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class TestLoginUI : public LoginUIService::LoginUI {
+ public:
+ TestLoginUI() { }
+ virtual ~TestLoginUI() { }
+ virtual void FocusUI() OVERRIDE { }
+ virtual 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:
+ virtual void OnLoginUIShown(LoginUIService::LoginUI* ui) OVERRIDE {
+ ++ui_shown_count_;
+ }
+
+ virtual void OnLoginUIClosed(LoginUIService::LoginUI* ui) OVERRIDE {
+ ++ui_closed_count_;
+ }
+
+ int ui_shown_count_;
+ int ui_closed_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestObserver);
+};
+
+class LoginUIServiceTest : public testing::Test {
+ public:
+ LoginUIServiceTest() { }
+ virtual ~LoginUIServiceTest() { }
+
+ protected:
+ LoginUIService service_;
+ TestObserver observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoginUIServiceTest);
+};
+
+TEST_F(LoginUIServiceTest, LoginUIChangedNotification) {
+ service_.AddObserver(&observer_);
+ EXPECT_EQ(NULL, service_.current_login_ui());
+ TestLoginUI ui;
+ service_.SetLoginUI(&ui);
+ EXPECT_EQ(1, observer_.ui_shown_count());
+ // If a different UI is closed than the one that was shown, no
+ // notification should be fired.
+ TestLoginUI other_ui;
+ service_.LoginUIClosed(&other_ui);
+ EXPECT_EQ(1, observer_.ui_shown_count());
+ // If the right UI is closed, notification shoudl be fired.
Andrew T Wilson (Slow) 2012/07/10 17:37:43 nit: shoudl->should
Munjal (Google) 2012/07/10 18:02:58 Done.
+ service_.LoginUIClosed(&ui);
+ EXPECT_EQ(1, observer_.ui_closed_count());
+ service_.RemoveObserver(&observer_);
+}

Powered by Google App Engine
This is Rietveld 408576698