OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/app_window_registry.h" | 5 #include "apps/app_window_registry.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chromeos/network/shill_property_util.h" | 22 #include "chromeos/network/shill_property_util.h" |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 char kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; | |
33 | |
34 base::FilePath GetTestDemoAppPath() { | 32 base::FilePath GetTestDemoAppPath() { |
35 base::FilePath test_data_dir; | 33 base::FilePath test_data_dir; |
36 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 34 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
37 return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app")); | 35 return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app")); |
38 } | 36 } |
39 | 37 |
40 Profile* WaitForProfile() { | 38 Profile* WaitForProfile() { |
41 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 39 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
42 if (!user_manager || !user_manager->IsUserLoggedIn()) { | 40 if (!user_manager || !user_manager->IsUserLoggedIn()) { |
43 content::WindowedNotificationObserver( | 41 content::WindowedNotificationObserver( |
44 chrome::NOTIFICATION_SESSION_STARTED, | 42 chrome::NOTIFICATION_SESSION_STARTED, |
45 content::NotificationService::AllSources()).Wait(); | 43 content::NotificationService::AllSources()).Wait(); |
46 } | 44 } |
47 | 45 |
48 return ProfileManager::GetActiveUserProfile(); | 46 return ProfileManager::GetActiveUserProfile(); |
49 } | 47 } |
50 | 48 |
51 bool VerifyDemoAppLaunch() { | 49 bool VerifyDemoAppLaunch() { |
52 Profile* profile = WaitForProfile(); | 50 Profile* profile = WaitForProfile(); |
53 return AppWindowWaiter(apps::AppWindowRegistry::Get(profile), | 51 return AppWindowWaiter(apps::AppWindowRegistry::Get(profile), |
54 kDemoAppId).Wait() != NULL; | 52 DemoAppLauncher::kDemoAppId).Wait() != NULL; |
55 } | 53 } |
56 | 54 |
57 bool VerifyNetworksDisabled() { | 55 bool VerifyNetworksDisabled() { |
58 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 56 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
59 return !handler->FirstNetworkByType(NetworkTypePattern::NonVirtual()); | 57 return !handler->FirstNetworkByType(NetworkTypePattern::NonVirtual()); |
60 } | 58 } |
61 | 59 |
62 } // namespace | 60 } // namespace |
63 | 61 |
64 class DemoAppLauncherTest : public ExtensionBrowserTest { | 62 class DemoAppLauncherTest : public ExtensionBrowserTest { |
(...skipping 30 matching lines...) Expand all Loading... |
95 // did launch. | 93 // did launch. |
96 EXPECT_TRUE(VerifyDemoAppLaunch()); | 94 EXPECT_TRUE(VerifyDemoAppLaunch()); |
97 } | 95 } |
98 | 96 |
99 IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, NoNetwork) { | 97 IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, NoNetwork) { |
100 EXPECT_TRUE(VerifyDemoAppLaunch()); | 98 EXPECT_TRUE(VerifyDemoAppLaunch()); |
101 EXPECT_TRUE(VerifyNetworksDisabled()); | 99 EXPECT_TRUE(VerifyNetworksDisabled()); |
102 } | 100 } |
103 | 101 |
104 } // namespace chromeos | 102 } // namespace chromeos |
OLD | NEW |