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

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc

Issue 13139004: Deprecate Browser::TYPE_PANEL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 <vector> 5 #include <vector>
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" 12 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h"
13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
14 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" 14 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/browser/ui/views/frame/browser_view.h" 17 #include "chrome/browser/ui/views/frame/browser_view.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/common/favicon_url.h" 23 #include "content/public/common/favicon_url.h"
24 #include "net/test/test_server.h" 24 #include "net/test/test_server.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 // TODO(skuhne): Remove this module together with launcher_favicon_loader.* 27 // TODO(stevenjb): Replace this using AshPanelContents (the current tests were
28 // when the old launcher goes away. 28 // writen using Browser Panels which no longer exist).
29
30 #if 0
29 31
30 namespace { 32 namespace {
31 33
32 // Observer class to determine when favicons have completed loading. 34 // Observer class to determine when favicons have completed loading.
33 class ContentsObserver : public content::WebContentsObserver { 35 class ContentsObserver : public content::WebContentsObserver {
34 public: 36 public:
35 explicit ContentsObserver(content::WebContents* web_contents) 37 explicit ContentsObserver(content::WebContents* web_contents)
36 : content::WebContentsObserver(web_contents), 38 : content::WebContentsObserver(web_contents),
37 got_favicons_(false) { 39 got_favicons_(false) {
38 } 40 }
(...skipping 14 matching lines...) Expand all
53 55
54 private: 56 private:
55 bool got_favicons_; 57 bool got_favicons_;
56 }; 58 };
57 59
58 } // namespace 60 } // namespace
59 61
60 class LauncherFaviconLoaderBrowsertest : public InProcessBrowserTest { 62 class LauncherFaviconLoaderBrowsertest : public InProcessBrowserTest {
61 public: 63 public:
62 LauncherFaviconLoaderBrowsertest() 64 LauncherFaviconLoaderBrowsertest()
63 : panel_browser_(NULL), 65 : browser_(NULL),
64 loader_(NULL), 66 loader_(NULL),
65 contents_observer_(NULL) { 67 contents_observer_(NULL) {
66 } 68 }
67 69
68 virtual ~LauncherFaviconLoaderBrowsertest() { 70 virtual ~LauncherFaviconLoaderBrowsertest() {
69 } 71 }
70 72
71 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 73 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
72 InProcessBrowserTest::SetUpCommandLine(command_line); 74 InProcessBrowserTest::SetUpCommandLine(command_line);
73 command_line->AppendSwitch(ash::switches::kAshDisablePerAppLauncher); 75 command_line->AppendSwitch(ash::switches::kAshDisablePerAppLauncher);
74 } 76 }
75 77
76 protected: 78 protected:
77 void NavigateTo(const char* url) { 79 void NavigateTo(const char* url) {
78 Browser* browser = GetPanelBrowser(); 80 Browser* browser = GetBrowser();
79 std::string url_path = base::StringPrintf("files/ash/launcher/%s", url); 81 std::string url_path = base::StringPrintf("files/ash/launcher/%s", url);
80 ui_test_utils::NavigateToURL(browser, test_server()->GetURL(url_path)); 82 ui_test_utils::NavigateToURL(browser, test_server()->GetURL(url_path));
81 } 83 }
82 84
83 Browser* GetPanelBrowser() { 85 Browser* GetBrowser() {
84 if (!panel_browser_) { 86 if (!browser_) {
85 panel_browser_ = new Browser(Browser::CreateParams::CreateForApp( 87 browser_ = new Browser(Browser::CreateParams::CreateForApp(
86 Browser::TYPE_PANEL, "Test Panel", gfx::Rect(), 88 Browser::TYPE_POPUP, "Test Popup", gfx::Rect(),
87 browser()->profile(), browser()->host_desktop_type())); 89 browser()->profile(), browser()->host_desktop_type()));
88 EXPECT_TRUE(panel_browser_->is_type_panel()); 90 EXPECT_TRUE(browser_->is_type_popup());
89 // Load initial web contents before setting the observer. 91 // Load initial web contents before setting the observer.
90 ui_test_utils::NavigateToURL(panel_browser_, GURL()); 92 ui_test_utils::NavigateToURL(browser_, GURL());
91 EXPECT_FALSE(contents_observer_.get()); 93 EXPECT_FALSE(contents_observer_.get());
92 contents_observer_.reset( 94 contents_observer_.reset(
93 new ContentsObserver( 95 new ContentsObserver(
94 panel_browser_->tab_strip_model()->GetWebContentsAt(0))); 96 browser_->tab_strip_model()->GetWebContentsAt(0)));
95 } 97 }
96 return panel_browser_; 98 return browser_;
97 } 99 }
98 100
99 LauncherFaviconLoader* GetFaviconLoader() { 101 LauncherFaviconLoader* GetFaviconLoader() {
100 if (!loader_) { 102 if (!loader_) {
101 Browser* browser = GetPanelBrowser(); 103 Browser* browser = GetBrowser();
102 BrowserView* browser_view = static_cast<BrowserView*>(browser->window()); 104 BrowserView* browser_view = static_cast<BrowserView*>(browser->window());
103 BrowserLauncherItemController* launcher_item_controller = 105 BrowserLauncherItemController* launcher_item_controller =
104 browser_view->launcher_item_controller(); 106 browser_view->launcher_item_controller();
105 if (!launcher_item_controller) 107 if (!launcher_item_controller)
106 return NULL; 108 return NULL;
107 EXPECT_EQ(BrowserLauncherItemController::TYPE_EXTENSION_PANEL, 109 EXPECT_EQ(BrowserLauncherItemController::TYPE_EXTENSION_PANEL,
108 launcher_item_controller->type()); 110 launcher_item_controller->type());
109 loader_ = launcher_item_controller->favicon_loader(); 111 loader_ = launcher_item_controller->favicon_loader();
110 } 112 }
111 return loader_; 113 return loader_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 NavigateTo("launcher-smallfavicon.html"); 193 NavigateTo("launcher-smallfavicon.html");
192 EXPECT_TRUE(WaitForFaviconDownloads()); 194 EXPECT_TRUE(WaitForFaviconDownloads());
193 EXPECT_TRUE(favicon_loader->GetFavicon().empty()); 195 EXPECT_TRUE(favicon_loader->GetFavicon().empty());
194 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); 196 ASSERT_NO_FATAL_FAILURE(ResetDownloads());
195 197
196 NavigateTo("launcher-largefavicon.html"); 198 NavigateTo("launcher-largefavicon.html");
197 EXPECT_TRUE(WaitForFaviconDownloads()); 199 EXPECT_TRUE(WaitForFaviconDownloads());
198 EXPECT_FALSE(favicon_loader->GetFavicon().empty()); 200 EXPECT_FALSE(favicon_loader->GetFavicon().empty());
199 EXPECT_EQ(128, favicon_loader->GetFavicon().height()); 201 EXPECT_EQ(128, favicon_loader->GetFavicon().height());
200 } 202 }
203
204 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698