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

Unified Diff: chrome/browser/ui/views/confirm_bubble_views_unittest.cc

Issue 12036094: Fix crash on spell check "Ask Google for suggestions" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/confirm_bubble_views_unittest.cc
diff --git a/chrome/browser/ui/views/confirm_bubble_views_unittest.cc b/chrome/browser/ui/views/confirm_bubble_views_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..90d78088e50f76739961d60b1f3978e80ce13951
--- /dev/null
+++ b/chrome/browser/ui/views/confirm_bubble_views_unittest.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/confirm_bubble_views.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/ui/confirm_bubble.h"
+#include "chrome/browser/ui/confirm_bubble_model.h"
+#include "grit/theme_resources.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget.h"
+
+using views::Widget;
+
+class TestConfirmBubbleModel : public ConfirmBubbleModel {
+ public:
+ TestConfirmBubbleModel() {}
+ virtual ~TestConfirmBubbleModel() {}
+
+ virtual string16 GetTitle() const OVERRIDE;
+ virtual string16 GetMessageText() const OVERRIDE;
+ virtual gfx::Image* GetIcon() const OVERRIDE;
+ virtual int GetButtons() const OVERRIDE;
+ virtual string16 GetButtonLabel(BubbleButton button) const OVERRIDE;
+ virtual void Accept() OVERRIDE {}
+ virtual void Cancel() OVERRIDE {}
+ virtual string16 GetLinkText() const OVERRIDE;
+ virtual void LinkClicked() OVERRIDE {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestConfirmBubbleModel);
+};
+
+string16 TestConfirmBubbleModel::GetTitle() const {
+ return ASCIIToUTF16("Title");
+}
+
+string16 TestConfirmBubbleModel::GetMessageText() const {
+ return ASCIIToUTF16("Message");
+}
+
+gfx::Image* TestConfirmBubbleModel::GetIcon() const {
+ return &ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_PRODUCT_LOGO_16);
+}
+
+int TestConfirmBubbleModel::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 TestConfirmBubbleModel::GetButtonLabel(BubbleButton button) const {
+ return button == BUTTON_OK ? ASCIIToUTF16("OK") : ASCIIToUTF16("Cancel");
+}
+
+string16 TestConfirmBubbleModel::GetLinkText() const {
+ return ASCIIToUTF16("Link");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+typedef views::ViewsTestBase ConfirmBubbleViewsTest;
+
+TEST_F(ConfirmBubbleViewsTest, CreateAndClose) {
Elliot Glaysher 2013/01/24 23:16:58 Thank you.
+ // Create parent widget, as confirm bubble must have an owner.
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ scoped_ptr<views::Widget> parent_widget(new Widget);
+ parent_widget->Init(params);
+ parent_widget->Show();
+
+ // Bubble owns the model.
+ ConfirmBubbleViews* bubble =
+ new ConfirmBubbleViews(parent_widget->GetNativeView(),
+ gfx::Point(12, 34),
+ new TestConfirmBubbleModel);
+ views::BubbleDelegateView::CreateBubble(bubble);
+ bubble->Show();
+
+ // We're anchored to a point, not a specific view or widget.
+ EXPECT_EQ("12,34", bubble->anchor_point().ToString());
+ EXPECT_FALSE(bubble->anchor_view());
+ EXPECT_FALSE(bubble->anchor_widget());
+
+ // Clean up.
+ bubble->GetWidget()->CloseNow();
+ parent_widget->CloseNow();
+}

Powered by Google App Engine
This is Rietveld 408576698