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

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

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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/time.h" 10 #include "base/time.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 bitmap.eraseColor(color); 42 bitmap.eraseColor(color);
43 return bitmap; 43 return bitmap;
44 } 44 }
45 45
46 class FaviconDelegate : public ui::MenuModelDelegate { 46 class FaviconDelegate : public ui::MenuModelDelegate {
47 public: 47 public:
48 FaviconDelegate() : was_called_(false) {} 48 FaviconDelegate() : was_called_(false) {}
49 49
50 virtual void OnIconChanged(int model_index) OVERRIDE { 50 virtual void OnIconChanged(int model_index) OVERRIDE {
51 was_called_ = true; 51 was_called_ = true;
52 MessageLoop::current()->Quit(); 52 base::MessageLoop::current()->Quit();
53 } 53 }
54 54
55 bool was_called() const { return was_called_; } 55 bool was_called() const { return was_called_; }
56 56
57 private: 57 private:
58 bool was_called_; 58 bool was_called_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(FaviconDelegate); 60 DISALLOW_COPY_AND_ASSIGN(FaviconDelegate);
61 }; 61 };
62 62
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 url1, url1_favicon, history::FAVICON, 537 url1, url1_favicon, history::FAVICON,
538 gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); 538 gfx::Image::CreateFrom1xBitmap(new_icon_bitmap));
539 539
540 // Will return the current icon (default) but start an anync call 540 // Will return the current icon (default) but start an anync call
541 // to retrieve the favicon from the favicon service. 541 // to retrieve the favicon from the favicon service.
542 gfx::Image default_icon; 542 gfx::Image default_icon;
543 back_model.GetIconAt(0, &default_icon); 543 back_model.GetIconAt(0, &default_icon);
544 544
545 // Make the favicon service run GetFavIconForURL, 545 // Make the favicon service run GetFavIconForURL,
546 // FaviconDelegate.OnIconChanged will be called. 546 // FaviconDelegate.OnIconChanged will be called.
547 MessageLoop::current()->Run(); 547 base::MessageLoop::current()->Run();
548 548
549 // Verify that the callback executed. 549 // Verify that the callback executed.
550 EXPECT_TRUE(favicon_delegate.was_called()); 550 EXPECT_TRUE(favicon_delegate.was_called());
551 551
552 // Verify the bitmaps match. 552 // Verify the bitmaps match.
553 gfx::Image valid_icon; 553 gfx::Image valid_icon;
554 // This time we will get the new favicon returned. 554 // This time we will get the new favicon returned.
555 back_model.GetIconAt(0, &valid_icon); 555 back_model.GetIconAt(0, &valid_icon);
556 556
557 SkBitmap default_icon_bitmap = *default_icon.ToSkBitmap(); 557 SkBitmap default_icon_bitmap = *default_icon.ToSkBitmap();
558 SkBitmap valid_icon_bitmap = *valid_icon.ToSkBitmap(); 558 SkBitmap valid_icon_bitmap = *valid_icon.ToSkBitmap();
559 559
560 SkAutoLockPixels a(new_icon_bitmap); 560 SkAutoLockPixels a(new_icon_bitmap);
561 SkAutoLockPixels b(valid_icon_bitmap); 561 SkAutoLockPixels b(valid_icon_bitmap);
562 SkAutoLockPixels c(default_icon_bitmap); 562 SkAutoLockPixels c(default_icon_bitmap);
563 // Verify we did not get the default favicon. 563 // Verify we did not get the default favicon.
564 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), 564 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(),
565 valid_icon_bitmap.getPixels(), 565 valid_icon_bitmap.getPixels(),
566 default_icon_bitmap.getSize())); 566 default_icon_bitmap.getSize()));
567 // Verify we did get the expected favicon. 567 // Verify we did get the expected favicon.
568 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), 568 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(),
569 valid_icon_bitmap.getPixels(), 569 valid_icon_bitmap.getPixels(),
570 new_icon_bitmap.getSize())); 570 new_icon_bitmap.getSize()));
571 571
572 // Make sure the browser deconstructor doesn't have problems. 572 // Make sure the browser deconstructor doesn't have problems.
573 browser->tab_strip_model()->CloseAllTabs(); 573 browser->tab_strip_model()->CloseAllTabs();
574 // This is required to prevent the message loop from hanging. 574 // This is required to prevent the message loop from hanging.
575 profile()->DestroyHistoryService(); 575 profile()->DestroyHistoryService();
576 } 576 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_audio_indicator_unittest.cc ('k') | chrome/browser/ui/toolbar/encoding_menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698