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

Side by Side Diff: chrome/browser/apps/window_controls_browsertest.cc

Issue 2551303003: Remove unused packaged app window controls code. (Closed)
Patch Set: Nit Created 4 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/apps/app_browsertest_util.h"
6 #include "chrome/browser/profiles/profile.h"
7 #include "components/infobars/core/infobar_delegate.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "extensions/browser/process_manager.h"
10 #include "extensions/common/switches.h"
11 #include "extensions/test/extension_test_message_listener.h"
12
13 class WindowControlsTest : public extensions::PlatformAppBrowserTest {
14 protected:
15 void SetUpCommandLine(base::CommandLine* command_line) override {
16 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
17 command_line->AppendSwitch(extensions::switches::kEnableAppWindowControls);
18 }
19 content::WebContents* GetWebContentsForExtensionWindow(
20 const extensions::Extension* extension);
21 };
22
23 content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow(
24 const extensions::Extension* extension) {
25 extensions::ProcessManager* process_manager =
26 extensions::ProcessManager::Get(profile());
27
28 // Lookup render view host for background page.
29 const extensions::ExtensionHost* extension_host =
30 process_manager->GetBackgroundHostForExtension(extension->id());
31
32 // Go through all active views, looking for the first window of the extension.
33 for (content::RenderFrameHost* host : process_manager->GetAllFrames()) {
34 // Filter out views not part of this extension
35 if (process_manager->GetExtensionForRenderFrameHost(host) == extension) {
36 // Filter out the background page view
37 content::WebContents* web_contents =
38 content::WebContents::FromRenderFrameHost(host);
39 if (web_contents != extension_host->web_contents())
40 return web_contents;
41 }
42 }
43 return nullptr;
44 }
45
46 IN_PROC_BROWSER_TEST_F(WindowControlsTest, CloseControlWorks) {
47 // Launch app and wait for window to show up
48 const extensions::Extension* extension =
49 LoadAndLaunchPlatformApp("window_controls/buttons", "window-opened");
50
51 // Find WebContents of window
52 content::WebContents* web_contents =
53 GetWebContentsForExtensionWindow(extension);
54 ASSERT_TRUE(web_contents != NULL);
55
56 // Send a left click on the "Close" button and wait for the close action
57 // to happen.
58 ExtensionTestMessageListener window_closed("window-closed", false);
59
60 // Send mouse click somewhere inside the [x] button
61 const int controlOffset = 25;
62 int x = web_contents->GetContainerBounds().size().width() - controlOffset;
63 int y = controlOffset;
64 content::SimulateMouseClickAt(web_contents,
65 0,
66 blink::WebMouseEvent::Button::Left,
67 gfx::Point(x, y));
68
69 ASSERT_TRUE(window_closed.WaitUntilSatisfied());
70 }
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698