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

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: . 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"
8 #include "chrome/browser/ui/base_window.h" 9 #include "chrome/browser/ui/base_window.h"
10 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/extensions/shell_window.h" 11 #include "chrome/browser/ui/extensions/shell_window.h"
12 #include "chrome/test/base/testing_profile.h"
10 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
11 14
15 namespace {
16
17 class TestShellWindowRegistryObserver
18 : public extensions::ShellWindowRegistry::Observer {
19 public:
20 explicit TestShellWindowRegistryObserver(Profile* profile)
21 : profile_(profile),
22 updates_(0) {
23 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this);
24 }
25 virtual ~TestShellWindowRegistryObserver() {
26 extensions::ShellWindowRegistry::Get(profile_)->RemoveObserver(this);
27 }
28
29 // Overridden from ShellWindowRegistry::Observer:
30 virtual void OnShellWindowAdded(ShellWindow* shell_window) {}
31 virtual void OnShellWindowUpdated(ShellWindow* shell_window) {
32 ++updates_;
33 }
34 virtual void OnShellWindowRemoved(ShellWindow* shell_window) {
35 }
36
37 int updates() { return updates_; }
38
39 private:
40 Profile* profile_;
41 int updates_;
42
43 DISALLOW_COPY_AND_ASSIGN(TestShellWindowRegistryObserver);
44 };
45
46 } // namespace
47
12 namespace extensions { 48 namespace extensions {
13 49
14 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) { 50 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) {
15 ExtensionTestMessageListener background_listener("background_ok", false); 51 ExtensionTestMessageListener background_listener("background_ok", false);
16 ExtensionTestMessageListener ready_listener("ready", true /* will_reply */); 52 ExtensionTestMessageListener ready_listener("ready", true /* will_reply */);
17 ExtensionTestMessageListener success_listener("success", false); 53 ExtensionTestMessageListener success_listener("success", false);
18 54
19 LoadAndLaunchPlatformApp("windows_api_bounds"); 55 LoadAndLaunchPlatformApp("windows_api_bounds");
20 ASSERT_TRUE(background_listener.WaitUntilSatisfied()); 56 ASSERT_TRUE(background_listener.WaitUntilSatisfied());
21 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); 57 ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
22 ShellWindow* window = GetFirstShellWindow(); 58 ShellWindow* window = GetFirstShellWindow();
23 59
24 gfx::Rect new_bounds(100, 200, 300, 400); 60 gfx::Rect new_bounds(100, 200, 300, 400);
25 window->GetBaseWindow()->SetBounds(new_bounds); 61 window->GetBaseWindow()->SetBounds(new_bounds);
26 62
27 // TODO(jeremya/asargent) figure out why in GTK the window doesn't end up 63 // TODO(jeremya/asargent) figure out why in GTK the window doesn't end up
28 // with exactly the bounds we set. Is it a bug in our shell window 64 // with exactly the bounds we set. Is it a bug in our shell window
29 // implementation? crbug.com/160252 65 // implementation? crbug.com/160252
30 #ifdef TOOLKIT_GTK 66 #ifdef TOOLKIT_GTK
31 int slop = 50; 67 int slop = 50;
32 #else 68 #else
33 int slop = 0; 69 int slop = 0;
34 #endif // !TOOLKIT_GTK 70 #endif // !TOOLKIT_GTK
35 71
36 ready_listener.Reply(base::IntToString(slop)); 72 ready_listener.Reply(base::IntToString(slop));
37 ASSERT_TRUE(success_listener.WaitUntilSatisfied()); 73 ASSERT_TRUE(success_listener.WaitUntilSatisfied());
38 } 74 }
39 75
76 // Tests chrome.app.window.setLauncherIcon.
77 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiSetLauncherIcon) {
78 scoped_ptr<TestShellWindowRegistryObserver> test_observer(
79 new TestShellWindowRegistryObserver(browser()->profile()));
80 ExtensionTestMessageListener listener("IconSet", false);
81 LoadAndLaunchPlatformApp("windows_api_set_launcher_icon");
82 ASSERT_TRUE(listener.WaitUntilSatisfied());
83
84 ShellWindow* shell_window = GetFirstShellWindow();
85 ASSERT_TRUE(shell_window);
86 EXPECT_FALSE(shell_window->launcher_icon_url().is_empty());
jeremya 2012/12/03 00:09:34 Perhaps we could have a slightly bolder assertion
stevenjb 2012/12/03 19:02:41 That introduces a dependency on the .js in the tes
87 EXPECT_EQ(1, test_observer->updates());
88 }
89
40 // TODO(asargent) - Fix onMinimzed event on OSX (crbug.com/162793) and figure 90 // TODO(asargent) - Fix onMinimzed event on OSX (crbug.com/162793) and figure
41 // out what to do about the fact that minimize events don't work under ubuntu 91 // out what to do about the fact that minimize events don't work under ubuntu
42 // unity (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073). 92 // unity (crbug.com/162794 and https://bugs.launchpad.net/unity/+bug/998073).
43 #if defined(TOOLKIT_VIEWS) 93 #if defined(TOOLKIT_VIEWS)
44 94
45 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) { 95 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) {
46 EXPECT_TRUE( 96 EXPECT_TRUE(
47 RunExtensionTest("platform_apps/windows_api_properties")) << message_; 97 RunExtensionTest("platform_apps/windows_api_properties")) << message_;
48 } 98 }
49 99
50 #endif // defined(TOOLKIT_VIEWS) 100 #endif // defined(TOOLKIT_VIEWS)
51 101
52 } // namespace extensions 102 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698