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

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

Issue 232773008: More removal of GTK code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | 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 "apps/app_window.h" 5 #include "apps/app_window.h"
6 #include "apps/app_window_registry.h" 6 #include "apps/app_window_registry.h"
7 #include "apps/ui/native_app_window.h" 7 #include "apps/ui/native_app_window.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/apps/app_browsertest_util.h" 10 #include "chrome/browser/apps/app_browsertest_util.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/extensions/features/feature_channel.h" 13 #include "chrome/common/extensions/features/feature_channel.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "ui/base/base_window.h" 15 #include "ui/base/base_window.h"
16 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
17 17
18 #ifdef TOOLKIT_GTK
19 #include "content/public/test/test_utils.h"
20 #endif
21
22 using apps::AppWindow; 18 using apps::AppWindow;
23 19
24 namespace { 20 namespace {
25 21
26 class TestAppWindowRegistryObserver : public apps::AppWindowRegistry::Observer { 22 class TestAppWindowRegistryObserver : public apps::AppWindowRegistry::Observer {
27 public: 23 public:
28 explicit TestAppWindowRegistryObserver(Profile* profile) 24 explicit TestAppWindowRegistryObserver(Profile* profile)
29 : profile_(profile), icon_updates_(0) { 25 : profile_(profile), icon_updates_(0) {
30 apps::AppWindowRegistry::Get(profile_)->AddObserver(this); 26 apps::AppWindowRegistry::Get(profile_)->AddObserver(this);
31 } 27 }
(...skipping 29 matching lines...) Expand all
61 57
62 LoadAndLaunchPlatformApp("windows_api_bounds"); 58 LoadAndLaunchPlatformApp("windows_api_bounds");
63 ASSERT_TRUE(background_listener.WaitUntilSatisfied()); 59 ASSERT_TRUE(background_listener.WaitUntilSatisfied());
64 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); 60 ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
65 AppWindow* window = GetFirstAppWindow(); 61 AppWindow* window = GetFirstAppWindow();
66 62
67 gfx::Rect new_bounds(100, 200, 300, 400); 63 gfx::Rect new_bounds(100, 200, 300, 400);
68 new_bounds.Inset(-window->GetBaseWindow()->GetFrameInsets()); 64 new_bounds.Inset(-window->GetBaseWindow()->GetFrameInsets());
69 window->GetBaseWindow()->SetBounds(new_bounds); 65 window->GetBaseWindow()->SetBounds(new_bounds);
70 66
71 // TODO(jeremya/asargent) figure out why in GTK the window doesn't end up
72 // with exactly the bounds we set. Is it a bug in our app window
73 // implementation? crbug.com/160252
74 #ifdef TOOLKIT_GTK
75 int slop = 50;
76 #else
77 int slop = 0; 67 int slop = 0;
78 #endif // !TOOLKIT_GTK
79
80 ready_listener.Reply(base::IntToString(slop)); 68 ready_listener.Reply(base::IntToString(slop));
81 69
82 #ifdef TOOLKIT_GTK
83 // TODO(asargent)- this is here to help track down the root cause of
84 // crbug.com/164735.
85 {
86 gfx::Rect last_bounds;
87 while (!success_listener.was_satisfied()) {
88 gfx::Rect current_bounds = window->GetBaseWindow()->GetBounds();
89 if (current_bounds != last_bounds) {
90 LOG(INFO) << "new bounds: " << current_bounds.ToString();
91 }
92 last_bounds = current_bounds;
93 content::RunAllPendingInMessageLoop();
94 }
95 }
96 #endif
97
98 ASSERT_TRUE(success_listener.WaitUntilSatisfied()); 70 ASSERT_TRUE(success_listener.WaitUntilSatisfied());
99 } 71 }
100 72
101 // Tests chrome.app.window.setIcon. 73 // Tests chrome.app.window.setIcon.
102 IN_PROC_BROWSER_TEST_F(ExperimentalPlatformAppBrowserTest, WindowsApiSetIcon) { 74 IN_PROC_BROWSER_TEST_F(ExperimentalPlatformAppBrowserTest, WindowsApiSetIcon) {
103 scoped_ptr<TestAppWindowRegistryObserver> test_observer( 75 scoped_ptr<TestAppWindowRegistryObserver> test_observer(
104 new TestAppWindowRegistryObserver(browser()->profile())); 76 new TestAppWindowRegistryObserver(browser()->profile()));
105 ExtensionTestMessageListener listener("IconSet", false); 77 ExtensionTestMessageListener listener("IconSet", false);
106 LoadAndLaunchPlatformApp("windows_api_set_icon"); 78 LoadAndLaunchPlatformApp("windows_api_set_icon");
107 EXPECT_EQ(0, test_observer->icon_updates()); 79 EXPECT_EQ(0, test_observer->icon_updates());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT_TRUE(RunPlatformAppTest( 125 EXPECT_TRUE(RunPlatformAppTest(
154 "platform_apps/windows_api_always_on_top/no_permissions")) << message_; 126 "platform_apps/windows_api_always_on_top/no_permissions")) << message_;
155 } 127 }
156 128
157 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiGet) { 129 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiGet) {
158 EXPECT_TRUE(RunPlatformAppTest("platform_apps/windows_api_get")) 130 EXPECT_TRUE(RunPlatformAppTest("platform_apps/windows_api_get"))
159 << message_; 131 << message_;
160 } 132 }
161 133
162 } // namespace extensions 134 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698