Commit 722ad8e0 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

In LockScreenAppState tests flush mojo after new note requests

Make sure every call to SendNewNoteRequest is followed by call to
FlushTrayActionForTesting, which should flush mojo pipes.
For most instances this was already the case, but it was missing in few
places - these were followed up with ExpectObservedStatesMatch, which
did fluch of its own (to ensure the mojo pipe is flushed in other
direction), which flushed the new note request as well, or were
expecting mojo call to have no effect.

With CL:1145692, this does not seem to be enough anymore, as flush in
ExpectObservedStatesMatch ends up handling only a single mojo message.

While here, replace checks for empty observed state changed with calls
to ExpectObservedStatesMatch.

TEST=run tets with CL:1145692 applied
BUG=872070

Change-Id: I58447ffe8315ddcd5917f0ce901ea5b2624b4e2a
Reviewed-on: https://chromium-review.googlesource.com/1170026
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581917}
parent 12c6eaa9
......@@ -571,6 +571,7 @@ class LockScreenAppStateTest : public BrowserWithTestWindowTest {
SetFirstRunCompletedIfNeeded(app_->id());
session_manager_->SetSessionState(session_manager::SessionState::LOCKED);
state_controller_->FlushTrayActionForTesting();
if (app_manager_->state() != TestAppManager::State::kStarted) {
ADD_FAILURE() << "Lock app manager Start not invoked.";
......@@ -770,8 +771,8 @@ TEST_F(LockScreenAppStateKioskUserTest, SetPrimaryProfile) {
EXPECT_EQ(TestAppManager::State::kNotInitialized, app_manager()->state());
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_FALSE(lock_screen_profile_creator()->Initialized());
ExpectObservedStatesMatch(std::vector<TrayActionState>(), "No state change.");
}
TEST_F(LockScreenAppStateNoStylusInputTest,
......@@ -787,7 +788,7 @@ TEST_F(LockScreenAppStateNoStylusInputTest,
EXPECT_EQ(TestAppManager::State::kStopped, app_manager()->state());
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
EXPECT_EQ(0u, observer()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(), "No state change.");
// Enable stylus input.
SetStylusEnabled();
......@@ -812,7 +813,7 @@ TEST_F(LockScreenAppStateNoStylusInputTest, StylusDetectedAfterInitialization) {
EXPECT_EQ(TestAppManager::State::kStopped, app_manager()->state());
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
EXPECT_EQ(0u, observer()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(), "No state change.");
// Given that the screen is locked, lock screen apps should become available.
session_manager()->SetSessionState(session_manager::SessionState::LOCKED);
......@@ -837,8 +838,7 @@ TEST_F(LockScreenAppStateTest, InitialState) {
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(), "No state change.");
}
TEST_F(LockScreenAppStateTest, SetPrimaryProfile) {
......@@ -848,7 +848,7 @@ TEST_F(LockScreenAppStateTest, SetPrimaryProfile) {
EXPECT_EQ(TestAppManager::State::kStopped, app_manager()->state());
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
EXPECT_EQ(0u, observer()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(), "No state change.");
}
TEST_F(LockScreenAppStateTest, SetPrimaryProfileWhenSessionLocked) {
......@@ -1030,9 +1030,8 @@ TEST_F(LockScreenAppStateTest, SessionUnlockedWhileStartingAppManager) {
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
state_controller()->FlushTrayActionForTesting();
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change on session unlock.");
// Test that subsequent session lock works as expected.
session_manager()->SetSessionState(session_manager::SessionState::LOCKED);
......@@ -1055,18 +1054,17 @@ TEST_F(LockScreenAppStateTest, AppManagerNoApp) {
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
state_controller()->FlushTrayActionForTesting();
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change on session lock.");
tray_action()->SendNewNoteRequest(
LockScreenNoteOrigin::kLockScreenButtonSwipe);
state_controller()->FlushTrayActionForTesting();
EXPECT_EQ(TrayActionState::kNotAvailable,
state_controller()->GetLockScreenNoteState());
state_controller()->FlushTrayActionForTesting();
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change on note request.");
// App manager should be started on next session lock.
session_manager()->SetSessionState(session_manager::SessionState::ACTIVE);
......@@ -1137,8 +1135,8 @@ TEST_F(LockScreenAppStateTest, HandleActionWhenNotAvaiable) {
LockScreenNoteOrigin::kLockScreenButtonSwipe);
state_controller()->FlushTrayActionForTesting();
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change on note request");
}
TEST_F(LockScreenAppStateTest, HandleAction) {
......@@ -1160,8 +1158,8 @@ TEST_F(LockScreenAppStateTest, HandleAction) {
// There should be no state change - the state_controller was already in
// launching state when the request was received.
EXPECT_EQ(0u, observer()->observed_states().size());
EXPECT_EQ(0u, tray_action()->observed_states().size());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change on repeated launch");
EXPECT_EQ(1, app_manager()->launch_count());
}
......@@ -1200,6 +1198,7 @@ TEST_F(LockScreenAppStateWebUiLockTest,
ASSERT_TRUE(InitializeNoteTakingApp(TrayActionState::kAvailable,
true /* enable_app_launch */));
tray_action()->SendNewNoteRequest(LockScreenNoteOrigin::kStylusEject);
state_controller()->FlushTrayActionForTesting();
ExpectObservedStatesMatch({TrayActionState::kLaunching},
"Launch on new note request");
......@@ -1219,8 +1218,8 @@ TEST_F(LockScreenAppStateWebUiLockTest,
// is closed/canceled before that.
state_controller()->NewNoteLaunchAnimationDone();
EXPECT_EQ(0, app_manager()->launch_count());
EXPECT_TRUE(observer()->observed_states().empty());
EXPECT_TRUE(tray_action()->observed_states().empty());
ExpectObservedStatesMatch(std::vector<TrayActionState>(),
"No state change if canceled");
}
TEST_F(LockScreenAppStateTest, AppWindowRegistration) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment