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

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

Issue 11316292: Add app.window.setIcon (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ShellWindowUpdate -> ShellWindowIconUpdated Created 8 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 | Annotate | Revision Log
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/string_number_conversions.h" 5 #include "base/string_number_conversions.h"
6 #include "chrome/browser/extensions/extension_test_message_listener.h" 6 #include "chrome/browser/extensions/extension_test_message_listener.h"
7 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 7 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
8 #include "chrome/browser/extensions/shell_window_registry.h"
9 #include "chrome/browser/ui/base_window.h"
10 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/extensions/native_app_window.h" 11 #include "chrome/browser/ui/extensions/native_app_window.h"
9 #include "chrome/browser/ui/extensions/shell_window.h" 12 #include "chrome/browser/ui/extensions/shell_window.h"
13 #include "chrome/test/base/testing_profile.h"
10 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
11 15
16 namespace {
17
18 class TestShellWindowRegistryObserver
19 : public extensions::ShellWindowRegistry::Observer {
20 public:
21 explicit TestShellWindowRegistryObserver(Profile* profile)
22 : profile_(profile),
23 icon_updates_(0) {
24 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this);
25 }
26 virtual ~TestShellWindowRegistryObserver() {
27 extensions::ShellWindowRegistry::Get(profile_)->RemoveObserver(this);
28 }
29
30 // Overridden from ShellWindowRegistry::Observer:
31 virtual void OnShellWindowAdded(ShellWindow* shell_window) {}
32 virtual void OnShellWindowIconUpdated(ShellWindow* shell_window) {
33 ++icon_updates_;
34 }
35 virtual void OnShellWindowRemoved(ShellWindow* shell_window) {
36 }
37
38 int icon_updates() { return icon_updates_; }
39
40 private:
41 Profile* profile_;
42 int icon_updates_;
43
44 DISALLOW_COPY_AND_ASSIGN(TestShellWindowRegistryObserver);
45 };
46
47 } // namespace
48
12 namespace extensions { 49 namespace extensions {
13 50
14 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) { 51 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) {
15 ExtensionTestMessageListener background_listener("background_ok", false); 52 ExtensionTestMessageListener background_listener("background_ok", false);
16 ExtensionTestMessageListener ready_listener("ready", true /* will_reply */); 53 ExtensionTestMessageListener ready_listener("ready", true /* will_reply */);
17 ExtensionTestMessageListener success_listener("success", false); 54 ExtensionTestMessageListener success_listener("success", false);
18 55
19 LoadAndLaunchPlatformApp("windows_api_bounds"); 56 LoadAndLaunchPlatformApp("windows_api_bounds");
20 ASSERT_TRUE(background_listener.WaitUntilSatisfied()); 57 ASSERT_TRUE(background_listener.WaitUntilSatisfied());
21 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); 58 ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
(...skipping 10 matching lines...) Expand all
32 #else 69 #else
33 int slop = 0; 70 int slop = 0;
34 #endif // !TOOLKIT_GTK 71 #endif // !TOOLKIT_GTK
35 72
36 ready_listener.Reply(base::IntToString(slop)); 73 ready_listener.Reply(base::IntToString(slop));
37 ASSERT_TRUE(success_listener.WaitUntilSatisfied()); 74 ASSERT_TRUE(success_listener.WaitUntilSatisfied());
38 75
39 CloseShellWindowsAndWaitForAppToExit(); 76 CloseShellWindowsAndWaitForAppToExit();
40 } 77 }
41 78
79 // Tests chrome.app.window.setIcon.
80 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiSetIcon) {
81 scoped_ptr<TestShellWindowRegistryObserver> test_observer(
82 new TestShellWindowRegistryObserver(browser()->profile()));
83 ExtensionTestMessageListener listener("IconSet", false);
84 LoadAndLaunchPlatformApp("windows_api_set_icon");
85 EXPECT_EQ(0, test_observer->icon_updates());
86
87 ASSERT_TRUE(listener.WaitUntilSatisfied());
88
89 ShellWindow* shell_window = GetFirstShellWindow();
90 ASSERT_TRUE(shell_window);
91 EXPECT_NE(std::string::npos,
92 shell_window->app_icon_url().spec().find("icon.png"));
93 EXPECT_EQ(1, test_observer->icon_updates());
94 }
95
42 // TODO(asargent) - Fix onMinimzed event on OSX (crbug.com/162793) and figure 96 // TODO(asargent) - Fix onMinimzed event on OSX (crbug.com/162793) and figure
43 // out what to do about the fact that minimize events don't work under ubuntu 97 // out what to do about the fact that minimize events don't work under ubuntu
44 // unity (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073). 98 // unity (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073).
45 #if defined(TOOLKIT_VIEWS) 99 #if defined(TOOLKIT_VIEWS)
46 100
47 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) { 101 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) {
48 EXPECT_TRUE( 102 EXPECT_TRUE(
49 RunPlatformAppTest("platform_apps/windows_api_properties")) << message_; 103 RunPlatformAppTest("platform_apps/windows_api_properties")) << message_;
50 } 104 }
51 105
52 #endif // defined(TOOLKIT_VIEWS) 106 #endif // defined(TOOLKIT_VIEWS)
53 107
54 } // namespace extensions 108 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698