Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / enrollment / enrollment_screen_browsertest.cc
blobcf74b670aeb15d391fd205ce3bd6b3ae7748b70e
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.
5 #include "base/basictypes.h"
6 #include "base/command_line.h"
7 #include "base/path_service.h"
8 #include "base/run_loop.h"
9 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
10 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h"
11 #include "chrome/browser/chromeos/login/wizard_controller.h"
12 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/chromeos_test_utils.h"
16 #include "content/public/test/test_utils.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h"
20 using testing::InvokeWithoutArgs;
21 using testing::Mock;
23 namespace chromeos {
25 class EnrollmentScreenTest : public WizardInProcessBrowserTest {
26 public:
27 EnrollmentScreenTest()
28 : WizardInProcessBrowserTest(
29 WizardController::kEnrollmentScreenName) {}
31 private:
32 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenTest);
35 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) {
36 ASSERT_TRUE(WizardController::default_controller() != NULL);
38 EnrollmentScreen* enrollment_screen =
39 WizardController::default_controller()->GetEnrollmentScreen();
40 ASSERT_TRUE(enrollment_screen != NULL);
42 base::RunLoop run_loop;
43 MockScreenObserver mock_screen_observer;
44 static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
45 &mock_screen_observer;
47 ASSERT_EQ(WizardController::default_controller()->current_screen(),
48 enrollment_screen);
50 EXPECT_CALL(mock_screen_observer,
51 OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED))
52 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
53 enrollment_screen->OnCancel();
54 content::RunThisRunLoop(&run_loop);
55 Mock::VerifyAndClearExpectations(&mock_screen_observer);
57 static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
58 WizardController::default_controller();
61 class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest {
62 public:
63 ProvisionedEnrollmentScreenTest() {}
65 private:
66 // Overridden from InProcessBrowserTest:
67 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
68 base::FilePath test_data_dir;
69 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath(
70 "app_mode", "kiosk_manifest", &test_data_dir));
71 command_line->AppendSwitchPath(
72 switches::kAppOemManifestFile,
73 test_data_dir.AppendASCII("kiosk_manifest.json"));
76 DISALLOW_COPY_AND_ASSIGN(ProvisionedEnrollmentScreenTest);
79 IN_PROC_BROWSER_TEST_F(ProvisionedEnrollmentScreenTest, TestBackButton) {
80 ASSERT_TRUE(WizardController::default_controller() != NULL);
82 EnrollmentScreen* enrollment_screen =
83 WizardController::default_controller()->GetEnrollmentScreen();
84 ASSERT_TRUE(enrollment_screen != NULL);
86 base::RunLoop run_loop;
87 MockScreenObserver mock_screen_observer;
88 static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
89 &mock_screen_observer;
91 ASSERT_EQ(WizardController::default_controller()->current_screen(),
92 enrollment_screen);
94 EXPECT_CALL(mock_screen_observer,
95 OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_BACK))
96 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
97 enrollment_screen->OnCancel();
98 content::RunThisRunLoop(&run_loop);
99 Mock::VerifyAndClearExpectations(&mock_screen_observer);
101 static_cast<WizardScreen*>(enrollment_screen)->screen_observer_ =
102 WizardController::default_controller();
105 } // namespace chromeos