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

Side by Side Diff: chrome/browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc

Issue 205713002: Add a basic demo mode browser test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "apps/app_window_registry.h"
6 #include "base/basictypes.h"
7 #include "base/command_line.h"
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "base/path_service.h"
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
13 #include "chrome/browser/chromeos/login/test/app_window_waiter.h"
14 #include "chrome/browser/chromeos/login/user_manager.h"
15 #include "chrome/browser/extensions/extension_browsertest.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/chrome_paths.h"
19 #include "chromeos/chromeos_switches.h"
20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h"
22 #include "content/public/test/test_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h"
24
25 namespace chromeos {
26
27 namespace {
28
29 char kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel";
30
31 base::FilePath GetTestDemoAppPath() {
32 base::FilePath test_data_dir;
33 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
34 return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app"));
35 }
36
37 Profile* WaitForProfile() {
38 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
39 if (!user_manager || !user_manager->IsUserLoggedIn()) {
40 content::WindowedNotificationObserver(
41 chrome::NOTIFICATION_SESSION_STARTED,
42 content::NotificationService::AllSources()).Wait();
43 }
44
45 return ProfileManager::GetActiveUserProfile();
46 }
47
48 bool VerifyDemoAppLaunch() {
49 Profile* profile = WaitForProfile();
50 return AppWindowWaiter(apps::AppWindowRegistry::Get(profile),
51 kDemoAppId).Wait() != NULL;
52 }
53
54 } // namespace
55
56 class DemoAppLauncherTest : public ExtensionBrowserTest {
57 public:
58 DemoAppLauncherTest() {
59 set_exit_when_last_browser_closes(false);
60 }
61
62 virtual ~DemoAppLauncherTest() {}
63
64 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
65 command_line->AppendSwitch(switches::kLoginManager);
66 command_line->AppendSwitch(switches::kForceLoginManagerInTests);
67 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
68
69 command_line->AppendSwitchASCII(switches::kDerelictIdleTimeout, "0");
70 command_line->AppendSwitchASCII(switches::kOobeTimerInterval, "0");
71 command_line->AppendSwitchASCII(switches::kDerelictDetectionTimeout, "0");
72 }
73
74 virtual void SetUp() OVERRIDE {
75 chromeos::DemoAppLauncher::SetDemoAppPathForTesting(GetTestDemoAppPath());
76 ExtensionBrowserTest::SetUp();
77 }
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(DemoAppLauncherTest);
81 };
82
83 IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, Basic) {
84 // This test is fairly unique in the sense that the test actually starts as
85 // soon as Chrome launches, so there isn't any typical "launch this test"
86 // steps that we need to take. All we can do is verify that our demo app
87 // did launch.
88 EXPECT_TRUE(VerifyDemoAppLaunch());
89 }
90
91 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc ('k') | chrome/browser/chromeos/login/kiosk_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698