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

Side by Side Diff: extensions/browser/api/app_window/app_window_apitest.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: nits rebase Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/apps/app_browsertest_util.h" 10 #include "chrome/browser/apps/app_browsertest_util.h"
(...skipping 12 matching lines...) Expand all
23 #if defined(OS_WIN) 23 #if defined(OS_WIN)
24 #include "ui/base/win/shell.h" 24 #include "ui/base/win/shell.h"
25 #endif 25 #endif
26 26
27 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
28 #include "base/mac/mac_util.h" 28 #include "base/mac/mac_util.h"
29 #endif 29 #endif
30 30
31 namespace extensions { 31 namespace extensions {
32 32
33 namespace {
34
35 class TestAppWindowRegistryObserver : public AppWindowRegistry::Observer {
36 public:
37 explicit TestAppWindowRegistryObserver(Profile* profile)
38 : profile_(profile), icon_updates_(0) {
39 AppWindowRegistry::Get(profile_)->AddObserver(this);
40 }
41 ~TestAppWindowRegistryObserver() override {
42 AppWindowRegistry::Get(profile_)->RemoveObserver(this);
43 }
44
45 // Overridden from AppWindowRegistry::Observer:
46 void OnAppWindowIconChanged(AppWindow* app_window) override {
47 ++icon_updates_;
48 }
49
50 int icon_updates() { return icon_updates_; }
51
52 private:
53 Profile* profile_;
54 int icon_updates_;
55
56 DISALLOW_COPY_AND_ASSIGN(TestAppWindowRegistryObserver);
57 };
58
59 } // namespace
60
61 using AppWindowApiTest = PlatformAppBrowserTest; 33 using AppWindowApiTest = PlatformAppBrowserTest;
62 using ExperimentalAppWindowApiTest = ExperimentalPlatformAppBrowserTest; 34 using ExperimentalAppWindowApiTest = ExperimentalPlatformAppBrowserTest;
63 35
64 // Tests chrome.app.window.setIcon. 36 // Tests chrome.app.window.setIcon.
65 // Flaky test crbug.com/716726 37 IN_PROC_BROWSER_TEST_F(ExperimentalAppWindowApiTest, SetIcon) {
66 IN_PROC_BROWSER_TEST_F(ExperimentalAppWindowApiTest, DISABLED_SetIcon) {
67 std::unique_ptr<TestAppWindowRegistryObserver> test_observer(
68 new TestAppWindowRegistryObserver(browser()->profile()));
69 ExtensionTestMessageListener listener("ready", true); 38 ExtensionTestMessageListener listener("ready", true);
70 39
71 // Launch the app and wait for it to be ready. 40 // Launch the app and wait for it to be ready.
72 LoadAndLaunchPlatformApp("windows_api_set_icon", &listener); 41 LoadAndLaunchPlatformApp("windows_api_set_icon", &listener);
73 EXPECT_EQ(0, test_observer->icon_updates());
74 listener.Reply(""); 42 listener.Reply("");
75 43
44 AppWindow* app_window = GetFirstAppWindow();
45 ASSERT_TRUE(app_window);
46
76 // Now wait until the WebContent has decoded the icon and chrome has 47 // Now wait until the WebContent has decoded the icon and chrome has
77 // processed it. This needs to be in a loop since the renderer runs in a 48 // processed it. This needs to be in a loop since the renderer runs in a
78 // different process. 49 // different process.
79 while (test_observer->icon_updates() < 1) { 50 while (app_window->custom_app_icon().IsEmpty()) {
80 base::RunLoop run_loop; 51 base::RunLoop run_loop;
msw 2017/06/01 19:47:29 optional nit: base::RunLoop().RunUntilIdle(); and
khmel 2017/06/01 21:55:47 Done.
81 run_loop.RunUntilIdle(); 52 run_loop.RunUntilIdle();
82 } 53 }
83 AppWindow* app_window = GetFirstAppWindow(); 54
84 ASSERT_TRUE(app_window);
85 EXPECT_NE(std::string::npos, 55 EXPECT_NE(std::string::npos,
86 app_window->app_icon_url().spec().find("icon.png")); 56 app_window->app_icon_url().spec().find("icon.png"));
87 EXPECT_EQ(1, test_observer->icon_updates());
88 } 57 }
89 58
90 // TODO(asargent) - Figure out what to do about the fact that minimize events 59 // TODO(asargent) - Figure out what to do about the fact that minimize events
91 // don't work under ubuntu unity. 60 // don't work under ubuntu unity.
92 // (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073). 61 // (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073).
93 // TODO(linux_aura) http://crbug.com/163931 62 // TODO(linux_aura) http://crbug.com/163931
94 // Flaky on Mac, http://crbug.com/232330 63 // Flaky on Mac, http://crbug.com/232330
95 #if defined(TOOLKIT_VIEWS) && !(defined(OS_LINUX) && !defined(OS_CHROMEOS) && de fined(USE_AURA)) 64 #if defined(TOOLKIT_VIEWS) && !(defined(OS_LINUX) && !defined(OS_CHROMEOS) && de fined(USE_AURA))
96 65
97 IN_PROC_BROWSER_TEST_F(AppWindowApiTest, Properties) { 66 IN_PROC_BROWSER_TEST_F(AppWindowApiTest, Properties) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 command_line->AppendSwitchASCII(switches::kAppId, 185 command_line->AppendSwitchASCII(switches::kAppId,
217 "jkghodnilhceideoidjikpgommlajknk"); 186 "jkghodnilhceideoidjikpgommlajknk");
218 187
219 EXPECT_TRUE(RunComponentExtensionTest( 188 EXPECT_TRUE(RunComponentExtensionTest(
220 "platform_apps/windows_api_ime/forced_app_mode_not_fullscreen")) 189 "platform_apps/windows_api_ime/forced_app_mode_not_fullscreen"))
221 << message_; 190 << message_;
222 } 191 }
223 #endif // OS_CHROMEOS 192 #endif // OS_CHROMEOS
224 193
225 } // namespace extensions 194 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698