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

Unified Diff: chrome/browser/ui/test/test_app_window_icon_observer.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: fix mac compile Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/test/test_app_window_icon_observer.cc
diff --git a/chrome/browser/ui/test/test_app_window_icon_observer.cc b/chrome/browser/ui/test/test_app_window_icon_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..afa2668303b02d174953f93fdcae1e4a7fa557b9
--- /dev/null
+++ b/chrome/browser/ui/test/test_app_window_icon_observer.cc
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/test/test_app_window_icon_observer.h"
+
+#include "base/run_loop.h"
+#include "extensions/browser/app_window/app_window.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
+
+TestAppWindowIconObserver::TestAppWindowIconObserver(
+ content::BrowserContext* context)
+ : context_(context) {
+ extensions::AppWindowRegistry::Get(context_)->AddObserver(this);
+}
+
+TestAppWindowIconObserver::~TestAppWindowIconObserver() {
+ extensions::AppWindowRegistry::Get(context_)->RemoveObserver(this);
+ for (aura::Window* window : windows_)
+ window->RemoveObserver(this);
+}
+
+void TestAppWindowIconObserver::WaitForIconUpdate() {
+ WaitForIconUpdates(1);
+}
+
+void TestAppWindowIconObserver::WaitForIconUpdates(int updates) {
+ base::RunLoop run_loop;
+ expected_icon_updates_ = updates + icon_updates_;
+ icon_updated_callback_ = run_loop.QuitClosure();
+ run_loop.Run();
+}
+
+void TestAppWindowIconObserver::OnAppWindowAdded(
+ extensions::AppWindow* app_window) {
+ aura::Window* window = app_window->GetNativeWindow();
+ window->AddObserver(this);
+ windows_.push_back(window);
+}
+
+void TestAppWindowIconObserver::OnAppWindowRemoved(
+ extensions::AppWindow* app_window) {
+ aura::Window* window = app_window->GetNativeWindow();
+ if (window) {
+ windows_.erase(std::find(windows_.begin(), windows_.end(), window));
+ window->RemoveObserver(this);
+ }
+}
+
+void TestAppWindowIconObserver::OnWindowPropertyChanged(aura::Window* window,
+ const void* key,
+ intptr_t old) {
+ if (key == aura::client::kAppIconKey) {
+ ++icon_updates_;
+ if (icon_updates_ == expected_icon_updates_ &&
+ !icon_updated_callback_.is_null()) {
+ base::ResetAndReturn(&icon_updated_callback_).Run();
+ }
+ }
+}
« no previous file with comments | « chrome/browser/ui/test/test_app_window_icon_observer.h ('k') | chrome/browser/ui/views/apps/chrome_native_app_window_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698