OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" | 5 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 namespace input_method { | 17 namespace input_method { |
18 namespace { | 18 namespace { |
19 | 19 |
20 class MockObserver { | 20 class MockObserver { |
21 public: | 21 public: |
22 MockObserver() | 22 MockObserver() |
23 : state_(InputMethodManager::STATE_TERMINATING), | 23 : state_(InputMethodManager::STATE_TERMINATING), |
24 update_state_count_(0) { } | 24 update_state_count_(0) { } |
25 | 25 |
26 void SetState(InputMethodManager::State new_state) { | 26 void SetState(InputMethodManager::UIState new_state) { |
27 ++update_state_count_; | 27 ++update_state_count_; |
28 state_ = new_state; | 28 state_ = new_state; |
29 } | 29 } |
30 | 30 |
31 base::Callback<void(InputMethodManager::State new_state)> AsCallback() { | 31 base::Callback<void(InputMethodManager::UIState new_state)> AsCallback() { |
32 return base::Bind(&MockObserver::SetState, base::Unretained(this)); | 32 return base::Bind(&MockObserver::SetState, base::Unretained(this)); |
33 } | 33 } |
34 | 34 |
35 int update_state_count() const { | 35 int update_state_count() const { |
36 return update_state_count_; | 36 return update_state_count_; |
37 } | 37 } |
38 | 38 |
39 InputMethodManager::State state() const { | 39 InputMethodManager::UIState state() const { return state_; } |
40 return state_; | |
41 } | |
42 | 40 |
43 private: | 41 private: |
44 InputMethodManager::State state_; | 42 InputMethodManager::UIState state_; |
45 int update_state_count_; | 43 int update_state_count_; |
46 | 44 |
47 DISALLOW_COPY_AND_ASSIGN(MockObserver); | 45 DISALLOW_COPY_AND_ASSIGN(MockObserver); |
48 }; | 46 }; |
49 | 47 |
50 } // anonymous namespace | 48 } // anonymous namespace |
51 | 49 |
52 TEST(BrowserStateMonitorLifetimeTest, TestConstruction) { | 50 TEST(BrowserStateMonitorLifetimeTest, TestConstruction) { |
53 MockObserver mock_observer; | 51 MockObserver mock_observer; |
54 BrowserStateMonitor monitor(mock_observer.AsCallback()); | 52 BrowserStateMonitor monitor(mock_observer.AsCallback()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Check if the state of the |mock_observer_| as well as the |monitor| are | 165 // Check if the state of the |mock_observer_| as well as the |monitor| are |
168 // both changed. | 166 // both changed. |
169 EXPECT_EQ(2, mock_observer_.update_state_count()); | 167 EXPECT_EQ(2, mock_observer_.update_state_count()); |
170 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, | 168 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, |
171 mock_observer_.state()); | 169 mock_observer_.state()); |
172 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor_.state()); | 170 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor_.state()); |
173 } | 171 } |
174 | 172 |
175 } // namespace input_method | 173 } // namespace input_method |
176 } // namespace chromeos | 174 } // namespace chromeos |
OLD | NEW |