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

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: 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 Profile* WaitForProfile() {
32 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
33 if (!user_manager || !user_manager->IsUserLoggedIn())
34 content::WindowedNotificationObserver(
35 chrome::NOTIFICATION_SESSION_STARTED,
36 content::NotificationService::AllSources()).Wait();
xiyuan 2014/03/26 21:58:19 nit: Wrap with enclosing {} since it is more than
rkc 2014/03/26 22:26:12 Done.
37
38 return ProfileManager::GetActiveUserProfile();
39 }
40
41 } // namespace
42
43 class DemoAppLauncherTest : public ExtensionBrowserTest {
44 public:
45 DemoAppLauncherTest() {
46 set_exit_when_last_browser_closes(false);
47 }
48
49 virtual ~DemoAppLauncherTest() {}
50
51 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
52 command_line->AppendSwitch(switches::kLoginManager);
53 command_line->AppendSwitch(switches::kForceLoginManagerInTests);
54 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
55
56 command_line->AppendSwitchASCII(switches::kDerelictIdleTimeout, "0");
57 command_line->AppendSwitchASCII(switches::kOobeTimerInterval, "0");
58 command_line->AppendSwitchASCII(switches::kDerelictDetectionTimeout, "0");
59 }
60
61 virtual void SetUp() OVERRIDE {
62 chromeos::DemoAppLauncher::SetDemoAppPathForTesting(GetTestDemoAppPath());
63 ExtensionBrowserTest::SetUp();
64 }
65
66 virtual void SetUpOnMainThread() OVERRIDE {
xiyuan 2014/03/26 21:58:19 nit: no need to override this.
rkc 2014/03/26 22:26:12 Done.
67 ExtensionBrowserTest::SetUpOnMainThread();
68 }
69
70 bool VerifyDemoAppLaunch() {
71 Profile* profile = WaitForProfile();
72 return AppWindowWaiter(apps::AppWindowRegistry::Get(profile),
73 kDemoAppId).Wait() != NULL;
74 }
75
76 private:
77 base::FilePath GetTestDemoAppPath() const {
78 base::FilePath test_data_dir;
79 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
80 return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app"));
81 }
82
83 DISALLOW_COPY_AND_ASSIGN(DemoAppLauncherTest);
84 };
85
86 IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, Basic) {
87 // This test is fairly unique in the sense that the test actually starts as
88 // soon as Chrome launches, so there isn't any typical "launch this test"
89 // steps that we need to take. All we can do is verify that our demo app
90 // did launch.
91 EXPECT_TRUE(VerifyDemoAppLaunch());
92 }
93
94 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698