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

Unified Diff: chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test fixed. Re-sorted methods of StateImpl and IMM. Created 6 years, 4 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/chromeos/input_method/browser_state_monitor_unittest.cc
diff --git a/chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc b/chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc
index 909c854deab310949537c2e6d5dab09e9f3631fc..6742a8574668746d23a65986e5da7a49ba5e5c9a 100644
--- a/chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc
+++ b/chrome/browser/chromeos/input_method/browser_state_monitor_unittest.cc
@@ -20,29 +20,26 @@ namespace {
class MockObserver {
public:
MockObserver()
- : state_(InputMethodManager::STATE_TERMINATING),
- update_state_count_(0) { }
+ : ui_session_(InputMethodManager::STATE_TERMINATING),
+ update_ui_session_count_(0) {}
- void SetState(InputMethodManager::State new_state) {
- ++update_state_count_;
- state_ = new_state;
+ void SetState(InputMethodManager::UISessionState new_ui_session) {
+ ++update_ui_session_count_;
+ ui_session_ = new_ui_session;
}
- base::Callback<void(InputMethodManager::State new_state)> AsCallback() {
+ base::Callback<void(InputMethodManager::UISessionState new_ui_session)>
+ AsCallback() {
return base::Bind(&MockObserver::SetState, base::Unretained(this));
}
- int update_state_count() const {
- return update_state_count_;
- }
+ int update_ui_session_count() const { return update_ui_session_count_; }
- InputMethodManager::State state() const {
- return state_;
- }
+ InputMethodManager::UISessionState ui_session() const { return ui_session_; }
private:
- InputMethodManager::State state_;
- int update_state_count_;
+ InputMethodManager::UISessionState ui_session_;
+ int update_ui_session_count_;
DISALLOW_COPY_AND_ASSIGN(MockObserver);
};
@@ -53,10 +50,10 @@ TEST(BrowserStateMonitorLifetimeTest, TestConstruction) {
MockObserver mock_observer;
BrowserStateMonitor monitor(mock_observer.AsCallback());
- // Check the initial state of the |mock_observer| and |monitor| objects.
- EXPECT_EQ(1, mock_observer.update_state_count());
- EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, mock_observer.state());
- EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, monitor.state());
+ // Check the initial ui_session_ of the |mock_observer| and |monitor| objects.
+ EXPECT_EQ(1, mock_observer.update_ui_session_count());
+ EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, mock_observer.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, monitor.ui_session());
}
namespace {
@@ -78,98 +75,97 @@ class BrowserStateMonitorTest : public testing::Test {
} // anonymous namespace
TEST_F(BrowserStateMonitorTest, TestObserveLoginUserChanged) {
- EXPECT_EQ(1, mock_observer_.update_state_count());
+ EXPECT_EQ(1, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
- // Check if the state of the |mock_observer_| as well as the |monitor| are
+ // Check if the ui_session of the |mock_observer_| as well as the |monitor|
+ // are
// both changed.
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.state());
+ mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.ui_session());
}
TEST_F(BrowserStateMonitorTest, TestObserveSessionStarted) {
- EXPECT_EQ(1, mock_observer_.update_state_count());
+ EXPECT_EQ(1, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
// Check if the state of the |mock_observer_| as well as the |monitor| are
// both changed.
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.state());
+ mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.ui_session());
}
TEST_F(BrowserStateMonitorTest, TestObserveLoginUserChangedThenSessionStarted) {
- EXPECT_EQ(1, mock_observer_.update_state_count());
+ EXPECT_EQ(1, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
// Check if the state of the |mock_observer_| as well as the |monitor| are
// both changed.
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.state());
+ mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.ui_session());
monitor_.Observe(chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
// The second notification should be nop.
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.state());
+ mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.ui_session());
}
TEST_F(BrowserStateMonitorTest, TestObserveScreenLockUnlock) {
- EXPECT_EQ(1, mock_observer_.update_state_count());
+ EXPECT_EQ(1, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
- EXPECT_EQ(2, mock_observer_.update_state_count());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
bool locked = true;
monitor_.Observe(chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::NotificationService::AllSources(),
content::Details<bool>(&locked));
- EXPECT_EQ(3, mock_observer_.update_state_count());
- EXPECT_EQ(InputMethodManager::STATE_LOCK_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_LOCK_SCREEN, monitor_.state());
+ EXPECT_EQ(3, mock_observer_.update_ui_session_count());
+ EXPECT_EQ(InputMethodManager::STATE_LOCK_SCREEN, mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_LOCK_SCREEN, monitor_.ui_session());
locked = false;
monitor_.Observe(chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
content::NotificationService::AllSources(),
content::Details<bool>(&locked));
- EXPECT_EQ(4, mock_observer_.update_state_count());
+ EXPECT_EQ(4, mock_observer_.update_ui_session_count());
EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.state());
+ mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_BROWSER_SCREEN, monitor_.ui_session());
}
TEST_F(BrowserStateMonitorTest, TestObserveAppTerminating) {
- EXPECT_EQ(1, mock_observer_.update_state_count());
+ EXPECT_EQ(1, mock_observer_.update_ui_session_count());
monitor_.Observe(chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
// Check if the state of the |mock_observer_| as well as the |monitor| are
// both changed.
- EXPECT_EQ(2, mock_observer_.update_state_count());
- EXPECT_EQ(InputMethodManager::STATE_TERMINATING,
- mock_observer_.state());
- EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor_.state());
+ EXPECT_EQ(2, mock_observer_.update_ui_session_count());
+ EXPECT_EQ(InputMethodManager::STATE_TERMINATING, mock_observer_.ui_session());
+ EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor_.ui_session());
}
} // namespace input_method

Powered by Google App Engine
This is Rietveld 408576698