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

Side by Side Diff: chrome/browser/chromeos/login/test/app_window_waiter.h

Issue 2576353002: Make AppWindowWaiter a common test support (Closed)
Patch Set: nits Created 4 years 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
OLDNEW
(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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "base/run_loop.h"
14 #include "extensions/browser/app_window/app_window_registry.h"
15
16 namespace extensions {
17 class AppWindow;
18 }
19
20 namespace chromeos {
21
22 // Helper class that monitors app windows to wait for a window to appear.
23 // Use a new instance for each use, one instance will only work for one Wait.
24 class AppWindowWaiter : public extensions::AppWindowRegistry::Observer {
25 public:
26 AppWindowWaiter(extensions::AppWindowRegistry* registry,
27 const std::string& app_id);
28 ~AppWindowWaiter() override;
29
30 // Waits for an AppWindow of the app to be added.
31 extensions::AppWindow* Wait();
32
33 // Waits for an AppWindow of the app to be shown.
34 extensions::AppWindow* WaitForShown();
35
36 // AppWindowRegistry::Observer:
37 void OnAppWindowAdded(extensions::AppWindow* app_window) override;
38 void OnAppWindowShown(extensions::AppWindow* app_window,
39 bool was_hidden) override;
40
41 private:
42 enum WaitType {
43 WAIT_FOR_NONE,
44 WAIT_FOR_ADDED,
45 WAIT_FOR_SHOWN,
46 };
47
48 extensions::AppWindowRegistry* const registry_;
49 const std::string app_id_;
50 std::unique_ptr<base::RunLoop> run_loop_;
51 WaitType wait_type_ = WAIT_FOR_NONE;
52 extensions::AppWindow* window_ = nullptr;
53
54 DISALLOW_COPY_AND_ASSIGN(AppWindowWaiter);
55 };
56
57 } // namespace chromeos
58
59 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/kiosk_browsertest.cc ('k') | chrome/browser/chromeos/login/test/app_window_waiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698