| 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 <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/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void ResetDownloads() { | 107 void ResetDownloads() { |
| 108 ASSERT_NE(static_cast<void*>(NULL), contents_observer_.get()); | 108 ASSERT_NE(static_cast<void*>(NULL), contents_observer_.get()); |
| 109 contents_observer_->Reset(); | 109 contents_observer_->Reset(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool WaitForFaviconDownlads(int expected) { | 112 bool WaitForFaviconDownlads(int expected) { |
| 113 const int64 max_seconds = 2; | 113 const int64 max_seconds = 2; |
| 114 base::Time start_time = base::Time::Now(); | 114 base::Time start_time = base::Time::Now(); |
| 115 while (!contents_observer_->got_favicons() || | 115 while (!contents_observer_->got_favicons() || |
| 116 contents_observer_->downloads_received() < expected) { | 116 contents_observer_->downloads_received() < expected) { |
| 117 ui_test_utils::RunAllPendingInMessageLoop(); | 117 content::RunAllPendingInMessageLoop(); |
| 118 base::TimeDelta delta = base::Time::Now() - start_time; | 118 base::TimeDelta delta = base::Time::Now() - start_time; |
| 119 if (delta.InSeconds() >= max_seconds) { | 119 if (delta.InSeconds() >= max_seconds) { |
| 120 LOG(ERROR) << " WaitForFaviconDownlads timed out:" | 120 LOG(ERROR) << " WaitForFaviconDownlads timed out:" |
| 121 << " Got Favicons:" << contents_observer_->got_favicons() | 121 << " Got Favicons:" << contents_observer_->got_favicons() |
| 122 << " Received: " << contents_observer_->downloads_received() | 122 << " Received: " << contents_observer_->downloads_received() |
| 123 << " / " << expected; | 123 << " / " << expected; |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 return true; | 127 return true; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 NavigateTo(panel_browser, "launcher-smallfavicon.html"); | 188 NavigateTo(panel_browser, "launcher-smallfavicon.html"); |
| 189 EXPECT_TRUE(WaitForFaviconDownlads(1)); | 189 EXPECT_TRUE(WaitForFaviconDownlads(1)); |
| 190 EXPECT_TRUE(favicon_loader->GetFavicon().empty()); | 190 EXPECT_TRUE(favicon_loader->GetFavicon().empty()); |
| 191 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); | 191 ASSERT_NO_FATAL_FAILURE(ResetDownloads()); |
| 192 | 192 |
| 193 NavigateTo(panel_browser, "launcher-largefavicon.html"); | 193 NavigateTo(panel_browser, "launcher-largefavicon.html"); |
| 194 EXPECT_TRUE(WaitForFaviconDownlads(1)); | 194 EXPECT_TRUE(WaitForFaviconDownlads(1)); |
| 195 EXPECT_FALSE(favicon_loader->GetFavicon().empty()); | 195 EXPECT_FALSE(favicon_loader->GetFavicon().empty()); |
| 196 EXPECT_EQ(128, favicon_loader->GetFavicon().height()); | 196 EXPECT_EQ(128, favicon_loader->GetFavicon().height()); |
| 197 } | 197 } |
| OLD | NEW |