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 "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" |
6 | 6 |
7 #include "ash/launcher/launcher_types.h" | 7 #include "ash/shelf/shelf_constants.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 | 17 |
17 using content::WebContents; | 18 using content::WebContents; |
18 using content::WebContentsObserver; | 19 using content::WebContentsObserver; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Observer class to determine when favicons have completed loading. | 23 // Observer class to determine when favicons have completed loading. |
23 class ContentsObserver : public WebContentsObserver { | 24 class ContentsObserver : public WebContentsObserver { |
24 public: | 25 public: |
25 explicit ContentsObserver(WebContents* web_contents) | 26 explicit ContentsObserver(WebContents* web_contents) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 151 } |
151 | 152 |
152 IN_PROC_BROWSER_TEST_F(LauncherFaviconLoaderBrowsertest, ManyLauncherIcons) { | 153 IN_PROC_BROWSER_TEST_F(LauncherFaviconLoaderBrowsertest, ManyLauncherIcons) { |
153 ASSERT_TRUE(test_server()->Start()); | 154 ASSERT_TRUE(test_server()->Start()); |
154 ASSERT_TRUE(NavigateTo("launcher-manyfavicon.html")); | 155 ASSERT_TRUE(NavigateTo("launcher-manyfavicon.html")); |
155 EXPECT_TRUE(WaitForContentsLoaded()); | 156 EXPECT_TRUE(WaitForContentsLoaded()); |
156 EXPECT_TRUE(WaitForFaviconUpdated()); | 157 EXPECT_TRUE(WaitForFaviconUpdated()); |
157 | 158 |
158 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); | 159 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); |
159 // When multiple favicons are present, the correctly sized icon should be | 160 // When multiple favicons are present, the correctly sized icon should be |
160 // chosen. The icons are sized assuming ash::kLauncherPreferredSize < 128. | 161 // chosen. The icons are sized assuming ash::kShelfPreferredSize < 128. |
161 EXPECT_GT(128, ash::kLauncherPreferredSize); | 162 EXPECT_GT(128, ash::kShelfPreferredSize); |
162 EXPECT_EQ(48, favicon_loader_->GetFavicon().height()); | 163 EXPECT_EQ(48, favicon_loader_->GetFavicon().height()); |
163 } | 164 } |
164 | 165 |
165 IN_PROC_BROWSER_TEST_F(LauncherFaviconLoaderBrowsertest, ChangeLauncherIcons) { | 166 IN_PROC_BROWSER_TEST_F(LauncherFaviconLoaderBrowsertest, ChangeLauncherIcons) { |
166 ASSERT_TRUE(test_server()->Start()); | 167 ASSERT_TRUE(test_server()->Start()); |
167 ASSERT_TRUE(NavigateTo("launcher-manyfavicon.html")); | 168 ASSERT_TRUE(NavigateTo("launcher-manyfavicon.html")); |
168 EXPECT_TRUE(WaitForContentsLoaded()); | 169 EXPECT_TRUE(WaitForContentsLoaded()); |
169 EXPECT_TRUE(WaitForFaviconUpdated()); | 170 EXPECT_TRUE(WaitForFaviconUpdated()); |
170 | 171 |
171 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); | 172 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); |
172 EXPECT_EQ(48, favicon_loader_->GetFavicon().height()); | 173 EXPECT_EQ(48, favicon_loader_->GetFavicon().height()); |
173 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); | 174 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); |
174 | 175 |
175 ASSERT_TRUE(NavigateTo("launcher-smallfavicon.html")); | 176 ASSERT_TRUE(NavigateTo("launcher-smallfavicon.html")); |
176 ASSERT_TRUE(WaitForContentsLoaded()); | 177 ASSERT_TRUE(WaitForContentsLoaded()); |
177 EXPECT_TRUE(WaitForFaviconUpdated()); | 178 EXPECT_TRUE(WaitForFaviconUpdated()); |
178 | 179 |
179 EXPECT_TRUE(favicon_loader_->GetFavicon().empty()); | 180 EXPECT_TRUE(favicon_loader_->GetFavicon().empty()); |
180 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); | 181 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); |
181 | 182 |
182 ASSERT_TRUE(NavigateTo("launcher-largefavicon.html")); | 183 ASSERT_TRUE(NavigateTo("launcher-largefavicon.html")); |
183 ASSERT_TRUE(WaitForContentsLoaded()); | 184 ASSERT_TRUE(WaitForContentsLoaded()); |
184 EXPECT_TRUE(WaitForFaviconUpdated()); | 185 EXPECT_TRUE(WaitForFaviconUpdated()); |
185 | 186 |
186 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); | 187 EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); |
187 EXPECT_EQ(128, favicon_loader_->GetFavicon().height()); | 188 EXPECT_EQ(128, favicon_loader_->GetFavicon().height()); |
188 } | 189 } |
OLD | NEW |