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

Side by Side Diff: chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 "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/string16.h" 8 #include "base/string16.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/history/history.h" 11 #include "chrome/browser/history/history.h"
12 #include "chrome/browser/history/history_service_factory.h" 12 #include "chrome/browser/history/history_service_factory.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
18 #include "chrome/test/base/test_browser_window.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
23 #include "content/public/test/web_contents_tester.h" 24 #include "content/public/test/web_contents_tester.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "ui/gfx/codec/png_codec.h" 27 #include "ui/gfx/codec/png_codec.h"
27 28
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 EXPECT_EQ(ASCIIToUTF16("A && B"), back_model->GetLabelAt(2)); 497 EXPECT_EQ(ASCIIToUTF16("A && B"), back_model->GetLabelAt(2));
497 EXPECT_EQ(ASCIIToUTF16("A &&&& B"), back_model->GetLabelAt(1)); 498 EXPECT_EQ(ASCIIToUTF16("A &&&& B"), back_model->GetLabelAt(1));
498 EXPECT_EQ(ASCIIToUTF16("A &&&&&& B"), back_model->GetLabelAt(0)); 499 EXPECT_EQ(ASCIIToUTF16("A &&&&&& B"), back_model->GetLabelAt(0));
499 #endif // defined(OS_MACOSX) 500 #endif // defined(OS_MACOSX)
500 } 501 }
501 502
502 // Test asynchronous loading of favicon from history service. 503 // Test asynchronous loading of favicon from history service.
503 TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { 504 TEST_F(BackFwdMenuModelTest, FaviconLoadTest) {
504 profile()->CreateHistoryService(true, false); 505 profile()->CreateHistoryService(true, false);
505 profile()->CreateFaviconService(); 506 profile()->CreateFaviconService();
506 Browser browser(Browser::TYPE_TABBED, profile()); 507 scoped_ptr<Browser> browser(
508 chrome::CreateBrowserWithTestWindowForProfile(profile()));
507 FaviconDelegate favicon_delegate; 509 FaviconDelegate favicon_delegate;
508 510
509 BackForwardMenuModel back_model( 511 BackForwardMenuModel back_model(
510 &browser, BackForwardMenuModel::BACKWARD_MENU); 512 browser.get(), BackForwardMenuModel::BACKWARD_MENU);
511 back_model.set_test_web_contents(controller().GetWebContents()); 513 back_model.set_test_web_contents(controller().GetWebContents());
512 back_model.SetMenuModelDelegate(&favicon_delegate); 514 back_model.SetMenuModelDelegate(&favicon_delegate);
513 515
514 SkBitmap new_icon_bitmap(CreateBitmap(SK_ColorRED)); 516 SkBitmap new_icon_bitmap(CreateBitmap(SK_ColorRED));
515 std::vector<unsigned char> icon_data; 517 std::vector<unsigned char> icon_data;
516 gfx::PNGCodec::EncodeBGRASkBitmap(new_icon_bitmap, false, &icon_data); 518 gfx::PNGCodec::EncodeBGRASkBitmap(new_icon_bitmap, false, &icon_data);
517 519
518 GURL url1 = GURL("http://www.a.com/1"); 520 GURL url1 = GURL("http://www.a.com/1");
519 GURL url2 = GURL("http://www.a.com/2"); 521 GURL url2 = GURL("http://www.a.com/2");
520 GURL url1_favicon("http://www.a.com/1/favicon.ico"); 522 GURL url1_favicon("http://www.a.com/1/favicon.ico");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // Verify we did not get the default favicon. 558 // Verify we did not get the default favicon.
557 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), 559 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(),
558 valid_icon_bitmap.getPixels(), 560 valid_icon_bitmap.getPixels(),
559 default_icon_bitmap.getSize())); 561 default_icon_bitmap.getSize()));
560 // Verify we did get the expected favicon. 562 // Verify we did get the expected favicon.
561 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), 563 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(),
562 valid_icon_bitmap.getPixels(), 564 valid_icon_bitmap.getPixels(),
563 new_icon_bitmap.getSize())); 565 new_icon_bitmap.getSize()));
564 566
565 // Make sure the browser deconstructor doesn't have problems. 567 // Make sure the browser deconstructor doesn't have problems.
566 chrome::CloseAllTabs(&browser); 568 chrome::CloseAllTabs(browser.get());
567 // This is required to prevent the message loop from hanging. 569 // This is required to prevent the message loop from hanging.
568 profile()->DestroyHistoryService(); 570 profile()->DestroyHistoryService();
569 } 571 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/pinned_tab_service_unittest.cc ('k') | chrome/browser/ui/views/ash/app_list/extension_app_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698