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

Side by Side Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 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
« no previous file with comments | « chrome/browser/chromeos/login/app_launch_controller.cc ('k') | chrome/browser/extensions/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/shell_window.h" 5 #include "apps/app_window.h"
6 #include "apps/shell_window_registry.h" 6 #include "apps/app_window_registry.h"
7 #include "apps/ui/native_app_window.h" 7 #include "apps/ui/native_app_window.h"
8 #include "ash/desktop_background/desktop_background_controller.h" 8 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_controller_observer.h" 9 #include "ash/desktop_background/desktop_background_controller_observer.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
16 #include "chrome/browser/chromeos/login/app_launch_controller.h" 16 #include "chrome/browser/chromeos/login/app_launch_controller.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 content::WebContents* web_contents_; 205 content::WebContents* web_contents_;
206 const std::string js_; 206 const std::string js_;
207 scoped_refptr<content::MessageLoopRunner> runner_; 207 scoped_refptr<content::MessageLoopRunner> runner_;
208 208
209 DISALLOW_COPY_AND_ASSIGN(JsConditionWaiter); 209 DISALLOW_COPY_AND_ASSIGN(JsConditionWaiter);
210 }; 210 };
211 211
212 } // namespace 212 } // namespace
213 213
214 // Helper class that monitors app windows to wait for a window to appear. 214 // Helper class that monitors app windows to wait for a window to appear.
215 class ShellWindowObserver : public apps::ShellWindowRegistry::Observer { 215 class AppWindowObserver : public apps::AppWindowRegistry::Observer {
216 public: 216 public:
217 ShellWindowObserver(apps::ShellWindowRegistry* registry, 217 AppWindowObserver(apps::AppWindowRegistry* registry,
218 const std::string& app_id) 218 const std::string& app_id)
219 : registry_(registry), app_id_(app_id), window_(NULL), running_(false) { 219 : registry_(registry), app_id_(app_id), window_(NULL), running_(false) {
220 registry_->AddObserver(this); 220 registry_->AddObserver(this);
221 } 221 }
222 virtual ~ShellWindowObserver() { 222 virtual ~AppWindowObserver() { registry_->RemoveObserver(this); }
223 registry_->RemoveObserver(this);
224 }
225 223
226 apps::ShellWindow* Wait() { 224 apps::AppWindow* Wait() {
227 running_ = true; 225 running_ = true;
228 message_loop_runner_ = new content::MessageLoopRunner; 226 message_loop_runner_ = new content::MessageLoopRunner;
229 message_loop_runner_->Run(); 227 message_loop_runner_->Run();
230 EXPECT_TRUE(window_); 228 EXPECT_TRUE(window_);
231 return window_; 229 return window_;
232 } 230 }
233 231
234 // ShellWindowRegistry::Observer 232 // AppWindowRegistry::Observer
235 virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE { 233 virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE {
236 if (!running_) 234 if (!running_)
237 return; 235 return;
238 236
239 if (shell_window->extension_id() == app_id_) { 237 if (app_window->extension_id() == app_id_) {
240 window_ = shell_window; 238 window_ = app_window;
241 message_loop_runner_->Quit(); 239 message_loop_runner_->Quit();
242 running_ = false; 240 running_ = false;
243 } 241 }
244 } 242 }
245 virtual void OnShellWindowIconChanged( 243 virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE {}
246 apps::ShellWindow* shell_window) OVERRIDE {} 244 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE {}
247 virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) OVERRIDE {}
248 245
249 private: 246 private:
250 apps::ShellWindowRegistry* registry_; 247 apps::AppWindowRegistry* registry_;
251 std::string app_id_; 248 std::string app_id_;
252 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 249 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
253 apps::ShellWindow* window_; 250 apps::AppWindow* window_;
254 bool running_; 251 bool running_;
255 252
256 DISALLOW_COPY_AND_ASSIGN(ShellWindowObserver); 253 DISALLOW_COPY_AND_ASSIGN(AppWindowObserver);
257 }; 254 };
258 255
259 class KioskTest : public OobeBaseTest { 256 class KioskTest : public OobeBaseTest {
260 public: 257 public:
261 KioskTest() { 258 KioskTest() {
262 set_exit_when_last_browser_closes(false); 259 set_exit_when_last_browser_closes(false);
263 } 260 }
264 261
265 virtual ~KioskTest() {} 262 virtual ~KioskTest() {}
266 263
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, 382 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
386 chromeos::KioskAppLaunchError::Get()); 383 chromeos::KioskAppLaunchError::Get());
387 384
388 // Check if the kiosk webapp is really installed for the default profile. 385 // Check if the kiosk webapp is really installed for the default profile.
389 const extensions::Extension* app = 386 const extensions::Extension* app =
390 extensions::ExtensionSystem::Get(app_profile)-> 387 extensions::ExtensionSystem::Get(app_profile)->
391 extension_service()->GetInstalledExtension(test_app_id_); 388 extension_service()->GetInstalledExtension(test_app_id_);
392 EXPECT_TRUE(app); 389 EXPECT_TRUE(app);
393 390
394 // App should appear with its window. 391 // App should appear with its window.
395 apps::ShellWindowRegistry* shell_window_registry = 392 apps::AppWindowRegistry* app_window_registry =
396 apps::ShellWindowRegistry::Get(app_profile); 393 apps::AppWindowRegistry::Get(app_profile);
397 apps::ShellWindow* window = 394 apps::AppWindow* window =
398 ShellWindowObserver(shell_window_registry, test_app_id_).Wait(); 395 AppWindowObserver(app_window_registry, test_app_id_).Wait();
399 EXPECT_TRUE(window); 396 EXPECT_TRUE(window);
400 397
401 // Login screen should be gone or fading out. 398 // Login screen should be gone or fading out.
402 chromeos::LoginDisplayHost* login_display_host = 399 chromeos::LoginDisplayHost* login_display_host =
403 chromeos::LoginDisplayHostImpl::default_host(); 400 chromeos::LoginDisplayHostImpl::default_host();
404 EXPECT_TRUE( 401 EXPECT_TRUE(
405 login_display_host == NULL || 402 login_display_host == NULL ||
406 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() == 403 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() ==
407 0.0f); 404 0.0f);
408 405
409 // Wait until the app terminates if it is still running. 406 // Wait until the app terminates if it is still running.
410 if (!shell_window_registry->GetShellWindowsForApp(test_app_id_).empty()) 407 if (!app_window_registry->GetAppWindowsForApp(test_app_id_).empty())
411 content::RunMessageLoop(); 408 content::RunMessageLoop();
412 409
413 // Check that the app had been informed that it is running in a kiosk 410 // Check that the app had been informed that it is running in a kiosk
414 // session. 411 // session.
415 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); 412 EXPECT_TRUE(launch_data_check_listener.was_satisfied());
416 } 413 }
417 414
418 void WaitForAppLaunchNetworkTimeout() { 415 void WaitForAppLaunchNetworkTimeout() {
419 if (GetAppLaunchController()->network_wait_timedout()) 416 if (GetAppLaunchController()->network_wait_timedout())
420 return; 417 return;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // Wait for the Kiosk App to launch. 991 // Wait for the Kiosk App to launch.
995 content::WindowedNotificationObserver( 992 content::WindowedNotificationObserver(
996 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, 993 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
997 content::NotificationService::AllSources()).Wait(); 994 content::NotificationService::AllSources()).Wait();
998 995
999 // Check installer status. 996 // Check installer status.
1000 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, 997 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
1001 chromeos::KioskAppLaunchError::Get()); 998 chromeos::KioskAppLaunchError::Get());
1002 999
1003 // Wait for the window to appear. 1000 // Wait for the window to appear.
1004 apps::ShellWindow* window = ShellWindowObserver( 1001 apps::AppWindow* window =
1005 apps::ShellWindowRegistry::Get(ProfileManager::GetPrimaryUserProfile()), 1002 AppWindowObserver(
1006 kTestEnterpriseKioskApp).Wait(); 1003 apps::AppWindowRegistry::Get(ProfileManager::GetPrimaryUserProfile()),
1004 kTestEnterpriseKioskApp).Wait();
1007 ASSERT_TRUE(window); 1005 ASSERT_TRUE(window);
1008 1006
1009 // Check whether the app can retrieve an OAuth2 access token. 1007 // Check whether the app can retrieve an OAuth2 access token.
1010 std::string result; 1008 std::string result;
1011 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 1009 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
1012 window->web_contents(), 1010 window->web_contents(),
1013 "chrome.identity.getAuthToken({ 'interactive': false }, function(token) {" 1011 "chrome.identity.getAuthToken({ 'interactive': false }, function(token) {"
1014 " window.domAutomationController.setAutomationId(0);" 1012 " window.domAutomationController.setAutomationId(0);"
1015 " window.domAutomationController.send(token);" 1013 " window.domAutomationController.send(token);"
1016 "});", 1014 "});",
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 content::WindowedNotificationObserver( 1091 content::WindowedNotificationObserver(
1094 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1092 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1095 content::NotificationService::AllSources()).Wait(); 1093 content::NotificationService::AllSources()).Wait();
1096 1094
1097 // Wait for the wallpaper to load. 1095 // Wait for the wallpaper to load.
1098 WaitForWallpaper(); 1096 WaitForWallpaper();
1099 EXPECT_TRUE(wallpaper_loaded()); 1097 EXPECT_TRUE(wallpaper_loaded());
1100 } 1098 }
1101 1099
1102 } // namespace chromeos 1100 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/app_launch_controller.cc ('k') | chrome/browser/extensions/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698