- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / enrollment / enrollment_screen_browsertest.cc
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 "base/basictypes.h"
6 #include "base/run_loop.h"
7 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
8 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h"
9 #include "chrome/browser/chromeos/login/wizard_controller.h"
10 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h"
11 #include "content/public/test/test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using testing::InvokeWithoutArgs;
16 using testing::Mock;
17
18 namespace chromeos {
19
20 class EnrollmentScreenTest : public WizardInProcessBrowserTest {
21  public:
22   EnrollmentScreenTest()
23       : WizardInProcessBrowserTest(
24             WizardController::kEnrollmentScreenName) {}
25
26  private:
27   DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenTest);
28 };
29
30 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) {
31   ASSERT_TRUE(WizardController::default_controller() != NULL);
32
33   EnrollmentScreen* enrollment_screen =
34       WizardController::default_controller()->GetEnrollmentScreen();
35   ASSERT_TRUE(enrollment_screen != NULL);
36
37   base::RunLoop run_loop;
38   MockScreenObserver mock_screen_observer;
39   static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
40       &mock_screen_observer;
41
42   ASSERT_EQ(WizardController::default_controller()->current_screen(),
43             enrollment_screen);
44
45   EXPECT_CALL(mock_screen_observer,
46               OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED))
47       .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
48   enrollment_screen->OnCancel();
49   content::RunThisRunLoop(&run_loop);
50   Mock::VerifyAndClearExpectations(&mock_screen_observer);
51
52   static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
53       WizardController::default_controller();
54 }
55
56 }  // namespace chromeos