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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/logging.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 class TestLoginUI : public LoginUIService::LoginUI {
12 public:
13 TestLoginUI() { }
14 virtual ~TestLoginUI() { }
15 virtual void FocusUI() OVERRIDE { }
16 virtual void CloseUI() OVERRIDE { }
17
18 private:
19 DISALLOW_COPY_AND_ASSIGN(TestLoginUI);
20 };
21
22 class TestObserver : public LoginUIService::Observer {
23 public:
24 TestObserver() : ui_shown_count_(0),
25 ui_closed_count_(0) {
26 }
27
28 int ui_shown_count() const { return ui_shown_count_; }
29 int ui_closed_count() const { return ui_closed_count_; }
30
31 private:
32 virtual void OnLoginUIShown(LoginUIService::LoginUI* ui) OVERRIDE {
33 ++ui_shown_count_;
34 }
35
36 virtual void OnLoginUIClosed(LoginUIService::LoginUI* ui) OVERRIDE {
37 ++ui_closed_count_;
38 }
39
40 int ui_shown_count_;
41 int ui_closed_count_;
42
43 DISALLOW_COPY_AND_ASSIGN(TestObserver);
44 };
45
46 class LoginUIServiceTest : public testing::Test {
47 public:
48 LoginUIServiceTest() { }
49 virtual ~LoginUIServiceTest() { }
50
51 protected:
52 LoginUIService service_;
53 TestObserver observer_;
54
55 DISALLOW_COPY_AND_ASSIGN(LoginUIServiceTest);
56 };
57
58 TEST_F(LoginUIServiceTest, LoginUIChangedNotification) {
James Hawkins 2012/07/10 20:41:15 nit: Document specifically what the test is testin
Munjal (Google) 2012/07/10 20:53:59 Done.
59 service_.AddObserver(&observer_);
60 EXPECT_EQ(NULL, service_.current_login_ui());
61 TestLoginUI ui;
62 service_.SetLoginUI(&ui);
63 EXPECT_EQ(1, observer_.ui_shown_count());
64 // If a different UI is closed than the one that was shown, no
James Hawkins 2012/07/10 20:41:15 Optional nit: Some whitespace around chunks of tes
Munjal (Google) 2012/07/10 20:53:59 Done.
65 // notification should be fired.
66 TestLoginUI other_ui;
67 service_.LoginUIClosed(&other_ui);
68 EXPECT_EQ(1, observer_.ui_shown_count());
69 // If the right UI is closed, notification should be fired.
70 service_.LoginUIClosed(&ui);
71 EXPECT_EQ(1, observer_.ui_closed_count());
72 service_.RemoveObserver(&observer_);
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698