OLD | NEW |
---|---|
(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(); | |
37 } | |
38 | |
39 return ProfileManager::GetActiveUserProfile(); | |
40 } | |
41 | |
42 } // namespace | |
43 | |
44 class DemoAppLauncherTest : public ExtensionBrowserTest { | |
45 public: | |
46 DemoAppLauncherTest() { | |
47 set_exit_when_last_browser_closes(false); | |
48 } | |
49 | |
50 virtual ~DemoAppLauncherTest() {} | |
51 | |
52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
53 command_line->AppendSwitch(switches::kLoginManager); | |
54 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | |
55 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | |
56 | |
57 command_line->AppendSwitchASCII(switches::kDerelictIdleTimeout, "0"); | |
58 command_line->AppendSwitchASCII(switches::kOobeTimerInterval, "0"); | |
59 command_line->AppendSwitchASCII(switches::kDerelictDetectionTimeout, "0"); | |
60 } | |
61 | |
62 virtual void SetUp() OVERRIDE { | |
63 chromeos::DemoAppLauncher::SetDemoAppPathForTesting(GetTestDemoAppPath()); | |
64 ExtensionBrowserTest::SetUp(); | |
65 } | |
66 | |
67 bool VerifyDemoAppLaunch() { | |
bartfab (slow)
2014/03/27 14:13:29
Nit: This does not access any |DemoAppLauncherTest
rkc
2014/03/27 21:43:10
Done.
| |
68 Profile* profile = WaitForProfile(); | |
69 return AppWindowWaiter(apps::AppWindowRegistry::Get(profile), | |
70 kDemoAppId).Wait() != NULL; | |
71 } | |
72 | |
73 private: | |
74 base::FilePath GetTestDemoAppPath() const { | |
bartfab (slow)
2014/03/27 14:13:29
Nit: This does not access any |DemoAppLauncherTest
rkc
2014/03/27 21:43:10
Done.
| |
75 base::FilePath test_data_dir; | |
76 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | |
77 return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app")); | |
78 } | |
79 | |
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 | |
OLD | NEW |