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

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

Issue 11411180: move favicon download code from chrome/ into content/ (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 <vector> 5 #include <vector>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" 9 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h"
10 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" 10 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/common/favicon_url.h"
15 #include "chrome/common/icon_messages.h"
16 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/favicon_download_delegate.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_delegate.h" 18 #include "content/public/browser/web_contents_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/common/favicon_url.h"
21 #include "net/test/test_server.h" 21 #include "net/test/test_server.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using content::FaviconURL;
25
26 using content::FaviconURL;
27
24 namespace { 28 namespace {
25 29
26 // Observer class to determine when favicons have completed loading. 30 // Observer class to determine when favicons have completed loading.
27 class ContentsObserver : public content::WebContentsObserver { 31 class ContentsObserver : public content::FaviconDownloadDelegate {
28 public: 32 public:
29 explicit ContentsObserver(content::WebContents* web_contents) 33 explicit ContentsObserver(content::WebContents* web_contents)
30 : content::WebContentsObserver(web_contents), 34 : got_favicons_(false) {
31 got_favicons_(false) { 35 web_contents->RegisterFaviconDelegate(this);
32 } 36 }
33 37
34 virtual ~ContentsObserver() {} 38 virtual ~ContentsObserver() {}
35 39
36 bool got_favicons() const { return got_favicons_; } 40 bool got_favicons() const { return got_favicons_; }
37 void Reset() { 41 void Reset() {
38 got_favicons_ = false; 42 got_favicons_ = false;
39 } 43 }
40 44
41 // content::WebContentsObserver overrides. 45 // content::FaviconDownloadDelegate overrides.
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 46 void UpdateFaviconURL(int32 page_id,
43 bool message_handled = false; // Allow other handlers to receive these.
44 IPC_BEGIN_MESSAGE_MAP(ContentsObserver, message)
45 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL)
46 IPC_MESSAGE_UNHANDLED(message_handled = false)
47 IPC_END_MESSAGE_MAP()
48 return message_handled;
49 }
50
51 private:
52 void OnUpdateFaviconURL(int32 page_id,
53 const std::vector<FaviconURL>& candidates) { 47 const std::vector<FaviconURL>& candidates) {
54 if (!candidates.empty()) 48 if (!candidates.empty())
55 got_favicons_ = true; 49 got_favicons_ = true;
56 } 50 }
57 51
52 private:
58 bool got_favicons_; 53 bool got_favicons_;
59 }; 54 };
60 55
61 } // namespace 56 } // namespace
62 57
63 class LauncherFaviconLoaderBrowsertest : public InProcessBrowserTest { 58 class LauncherFaviconLoaderBrowsertest : public InProcessBrowserTest {
64 public: 59 public:
65 LauncherFaviconLoaderBrowsertest() 60 LauncherFaviconLoaderBrowsertest()
66 : panel_browser_(NULL), 61 : panel_browser_(NULL),
67 loader_(NULL), 62 loader_(NULL),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 NavigateTo("launcher-smallfavicon.html"); 183 NavigateTo("launcher-smallfavicon.html");
189 EXPECT_TRUE(WaitForFaviconDownloads()); 184 EXPECT_TRUE(WaitForFaviconDownloads());
190 EXPECT_TRUE(favicon_loader->GetFavicon().empty()); 185 EXPECT_TRUE(favicon_loader->GetFavicon().empty());
191 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); 186 ASSERT_NO_FATAL_FAILURE(ResetDownloads());
192 187
193 NavigateTo("launcher-largefavicon.html"); 188 NavigateTo("launcher-largefavicon.html");
194 EXPECT_TRUE(WaitForFaviconDownloads()); 189 EXPECT_TRUE(WaitForFaviconDownloads());
195 EXPECT_FALSE(favicon_loader->GetFavicon().empty()); 190 EXPECT_FALSE(favicon_loader->GetFavicon().empty());
196 EXPECT_EQ(128, favicon_loader->GetFavicon().height()); 191 EXPECT_EQ(128, favicon_loader->GetFavicon().height());
197 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698