OLD | NEW |
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/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "chrome/browser/extensions/extension_test_message_listener.h" | 7 #include "chrome/browser/extensions/extension_test_message_listener.h" |
8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
9 #include "chrome/browser/extensions/shell_window_registry.h" | 9 #include "chrome/browser/extensions/shell_window_registry.h" |
10 #include "chrome/browser/ui/base_window.h" | 10 #include "chrome/browser/ui/base_window.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/extensions/native_app_window.h" | 12 #include "chrome/browser/ui/extensions/native_app_window.h" |
13 #include "chrome/browser/ui/extensions/shell_window.h" | 13 #include "chrome/browser/ui/extensions/shell_window.h" |
14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
| 17 #ifdef TOOLKIT_GTK |
| 18 #include "content/public/test/test_utils.h" |
| 19 #endif |
| 20 |
17 namespace { | 21 namespace { |
18 | 22 |
19 class TestShellWindowRegistryObserver | 23 class TestShellWindowRegistryObserver |
20 : public extensions::ShellWindowRegistry::Observer { | 24 : public extensions::ShellWindowRegistry::Observer { |
21 public: | 25 public: |
22 explicit TestShellWindowRegistryObserver(Profile* profile) | 26 explicit TestShellWindowRegistryObserver(Profile* profile) |
23 : profile_(profile), | 27 : profile_(profile), |
24 icon_updates_(0) { | 28 icon_updates_(0) { |
25 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this); | 29 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this); |
26 } | 30 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // TODO(jeremya/asargent) figure out why in GTK the window doesn't end up | 69 // TODO(jeremya/asargent) figure out why in GTK the window doesn't end up |
66 // with exactly the bounds we set. Is it a bug in our shell window | 70 // with exactly the bounds we set. Is it a bug in our shell window |
67 // implementation? crbug.com/160252 | 71 // implementation? crbug.com/160252 |
68 #ifdef TOOLKIT_GTK | 72 #ifdef TOOLKIT_GTK |
69 int slop = 50; | 73 int slop = 50; |
70 #else | 74 #else |
71 int slop = 0; | 75 int slop = 0; |
72 #endif // !TOOLKIT_GTK | 76 #endif // !TOOLKIT_GTK |
73 | 77 |
74 ready_listener.Reply(base::IntToString(slop)); | 78 ready_listener.Reply(base::IntToString(slop)); |
| 79 |
| 80 #ifdef TOOLKIT_GTK |
| 81 // TODO(asargent)- this is here to help track down the root cause of |
| 82 // crbug.com/164735. |
| 83 { |
| 84 gfx::Rect last_bounds; |
| 85 while (!success_listener.was_satisfied()) { |
| 86 gfx::Rect current_bounds = window->GetBaseWindow()->GetBounds(); |
| 87 if (current_bounds != last_bounds) { |
| 88 LOG(INFO) << "new bounds: " << current_bounds.ToString(); |
| 89 } |
| 90 last_bounds = current_bounds; |
| 91 content::RunAllPendingInMessageLoop(); |
| 92 } |
| 93 } |
| 94 #endif |
| 95 |
75 ASSERT_TRUE(success_listener.WaitUntilSatisfied()); | 96 ASSERT_TRUE(success_listener.WaitUntilSatisfied()); |
76 } | 97 } |
77 | 98 |
78 // Tests chrome.app.window.setIcon. | 99 // Tests chrome.app.window.setIcon. |
79 IN_PROC_BROWSER_TEST_F(ExperimentalPlatformAppBrowserTest, WindowsApiSetIcon) { | 100 IN_PROC_BROWSER_TEST_F(ExperimentalPlatformAppBrowserTest, WindowsApiSetIcon) { |
80 scoped_ptr<TestShellWindowRegistryObserver> test_observer( | 101 scoped_ptr<TestShellWindowRegistryObserver> test_observer( |
81 new TestShellWindowRegistryObserver(browser()->profile())); | 102 new TestShellWindowRegistryObserver(browser()->profile())); |
82 ExtensionTestMessageListener listener("IconSet", false); | 103 ExtensionTestMessageListener listener("IconSet", false); |
83 LoadAndLaunchPlatformApp("windows_api_set_icon"); | 104 LoadAndLaunchPlatformApp("windows_api_set_icon"); |
84 EXPECT_EQ(0, test_observer->icon_updates()); | 105 EXPECT_EQ(0, test_observer->icon_updates()); |
(...skipping 19 matching lines...) Expand all Loading... |
104 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) | 125 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) |
105 | 126 |
106 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) { | 127 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) { |
107 EXPECT_TRUE( | 128 EXPECT_TRUE( |
108 RunExtensionTest("platform_apps/windows_api_properties")) << message_; | 129 RunExtensionTest("platform_apps/windows_api_properties")) << message_; |
109 } | 130 } |
110 | 131 |
111 #endif // defined(TOOLKIT_VIEWS) | 132 #endif // defined(TOOLKIT_VIEWS) |
112 | 133 |
113 } // namespace extensions | 134 } // namespace extensions |
OLD | NEW |