OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/toolbar/back_forward_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
15 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
16 #include "content/browser/renderer_host/test_render_view_host.h" | |
17 #include "content/browser/tab_contents/navigation_controller.h" | 17 #include "content/browser/tab_contents/navigation_controller.h" |
18 #include "content/browser/tab_contents/navigation_entry.h" | 18 #include "content/browser/tab_contents/navigation_entry.h" |
19 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
20 #include "content/browser/tab_contents/test_tab_contents.h" | 20 #include "content/browser/tab_contents/test_tab_contents.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
23 #include "ui/gfx/codec/png_codec.h" | 23 #include "ui/gfx/codec/png_codec.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
(...skipping 18 matching lines...) Expand all Loading... |
45 bool was_called() const { return was_called_; } | 45 bool was_called() const { return was_called_; } |
46 | 46 |
47 private: | 47 private: |
48 bool was_called_; | 48 bool was_called_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(FaviconDelegate); | 50 DISALLOW_COPY_AND_ASSIGN(FaviconDelegate); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 class BackFwdMenuModelTest : public RenderViewHostTestHarness { | 55 class BackFwdMenuModelTest : public ChromeRenderViewHostTestHarness { |
56 public: | 56 public: |
57 BackFwdMenuModelTest() | 57 BackFwdMenuModelTest() |
58 : ui_thread_(BrowserThread::UI, &message_loop_) { | 58 : ui_thread_(BrowserThread::UI, &message_loop_) { |
59 } | 59 } |
60 | 60 |
61 void ValidateModel(BackForwardMenuModel* model, int history_items, | 61 void ValidateModel(BackForwardMenuModel* model, int history_items, |
62 int chapter_stops) { | 62 int chapter_stops) { |
63 int h = std::min(BackForwardMenuModel::kMaxHistoryItems, history_items); | 63 int h = std::min(BackForwardMenuModel::kMaxHistoryItems, history_items); |
64 int c = std::min(BackForwardMenuModel::kMaxChapterStops, chapter_stops); | 64 int c = std::min(BackForwardMenuModel::kMaxChapterStops, chapter_stops); |
65 EXPECT_EQ(h, model->GetHistoryItemCount()); | 65 EXPECT_EQ(h, model->GetHistoryItemCount()); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // Verify we did get the expected favicon. | 548 // Verify we did get the expected favicon. |
549 EXPECT_EQ(0, memcmp(new_icon.getPixels(), valid_icon.getPixels(), | 549 EXPECT_EQ(0, memcmp(new_icon.getPixels(), valid_icon.getPixels(), |
550 new_icon.getSize())); | 550 new_icon.getSize())); |
551 | 551 |
552 // Make sure the browser deconstructor doesn't have problems. | 552 // Make sure the browser deconstructor doesn't have problems. |
553 browser.CloseAllTabs(); | 553 browser.CloseAllTabs(); |
554 // This is required to prevent the message loop from hanging. | 554 // This is required to prevent the message loop from hanging. |
555 profile()->DestroyHistoryService(); | 555 profile()->DestroyHistoryService(); |
556 } | 556 } |
557 | 557 |
OLD | NEW |