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 "chrome/browser/chromeos/login/test/app_window_waiter.h" |
| 6 |
| 7 #include "apps/app_window.h" |
| 8 #include "content/public/test/test_utils.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 AppWindowWaiter::AppWindowWaiter(apps::AppWindowRegistry* registry, |
| 14 const std::string& app_id) |
| 15 : registry_(registry), app_id_(app_id), window_(NULL) { |
| 16 registry_->AddObserver(this); |
| 17 } |
| 18 |
| 19 AppWindowWaiter::~AppWindowWaiter() { |
| 20 registry_->RemoveObserver(this); |
| 21 } |
| 22 |
| 23 apps::AppWindow* AppWindowWaiter::Wait() { |
| 24 window_ = registry_->GetCurrentAppWindowForApp(app_id_); |
| 25 if (window_) |
| 26 return window_; |
| 27 |
| 28 run_loop_.Run(); |
| 29 |
| 30 return window_; |
| 31 } |
| 32 |
| 33 void AppWindowWaiter::OnAppWindowAdded(apps::AppWindow* app_window) { |
| 34 if (!run_loop_.running()) |
| 35 return; |
| 36 |
| 37 if (app_window->extension_id() == app_id_) { |
| 38 window_ = app_window; |
| 39 run_loop_.Quit(); |
| 40 } |
| 41 } |
| 42 |
| 43 void AppWindowWaiter::OnAppWindowIconChanged(apps::AppWindow* app_window) {} |
| 44 |
| 45 void AppWindowWaiter::OnAppWindowRemoved(apps::AppWindow* app_window) {} |
| 46 |
| 47 } // namespace chromeos |
OLD | NEW |