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), running_(false) { | |
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 running_ = true; | |
29 message_loop_runner_ = new content::MessageLoopRunner; | |
30 message_loop_runner_->Run(); | |
31 | |
32 EXPECT_TRUE(window_); | |
bartfab (slow)
2014/03/25 12:52:54
Nit: I think it would be better to let individual
rkc
2014/03/26 21:30:40
Done.
| |
33 return window_; | |
34 } | |
35 | |
36 void AppWindowWaiter::OnAppWindowAdded(apps::AppWindow* app_window) { | |
37 if (!running_) | |
38 return; | |
39 | |
40 if (app_window->extension_id() == app_id_) { | |
41 window_ = app_window; | |
42 message_loop_runner_->Quit(); | |
43 running_ = false; | |
bartfab (slow)
2014/03/25 12:52:54
Nit: If you just did message_loop_runner_ = NULL h
rkc
2014/03/26 21:30:40
Using run_loop_->running() instead.
Done.
| |
44 } | |
45 } | |
46 | |
47 void AppWindowWaiter::OnAppWindowIconChanged(apps::AppWindow* app_window) {} | |
48 | |
49 void AppWindowWaiter::OnAppWindowRemoved(apps::AppWindow* app_window) {} | |
50 | |
51 } // namespace chromeos | |
OLD | NEW |