| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/search_engines/template_url_service_factory.h" | 6 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 7 #include "chrome/browser/ui/views/first_run_bubble.h" | 7 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "components/search_engines/template_url.h" | 9 #include "components/search_engines/template_url.h" |
| 10 #include "components/search_engines/template_url_service.h" | 10 #include "components/search_engines/template_url_service.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 TemplateURLService* turl_model = | 82 TemplateURLService* turl_model = |
| 83 TemplateURLServiceFactory::GetForProfile(profile()); | 83 TemplateURLServiceFactory::GetForProfile(profile()); |
| 84 turl_model->Load(); | 84 turl_model->Load(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void FirstRunBubbleTest::CreateAndCloseBubbleOnEventTest(ui::Event* event) { | 87 void FirstRunBubbleTest::CreateAndCloseBubbleOnEventTest(ui::Event* event) { |
| 88 // Create the anchor and parent widgets. | 88 // Create the anchor and parent widgets. |
| 89 views::Widget::InitParams params = | 89 views::Widget::InitParams params = |
| 90 CreateParams(views::Widget::InitParams::TYPE_WINDOW); | 90 CreateParams(views::Widget::InitParams::TYPE_WINDOW); |
| 91 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 91 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 92 scoped_ptr<views::Widget> anchor_widget(new views::Widget); | 92 std::unique_ptr<views::Widget> anchor_widget(new views::Widget); |
| 93 anchor_widget->Init(params); | 93 anchor_widget->Init(params); |
| 94 anchor_widget->SetBounds(gfx::Rect(10, 10, 500, 500)); | 94 anchor_widget->SetBounds(gfx::Rect(10, 10, 500, 500)); |
| 95 anchor_widget->Show(); | 95 anchor_widget->Show(); |
| 96 | 96 |
| 97 FirstRunBubble* delegate = | 97 FirstRunBubble* delegate = |
| 98 FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView()); | 98 FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView()); |
| 99 EXPECT_TRUE(delegate != NULL); | 99 EXPECT_TRUE(delegate != NULL); |
| 100 | 100 |
| 101 anchor_widget->GetFocusManager()->SetFocusedView( | 101 anchor_widget->GetFocusManager()->SetFocusedView( |
| 102 anchor_widget->GetContentsView()); | 102 anchor_widget->GetContentsView()); |
| 103 | 103 |
| 104 scoped_ptr<WidgetClosingObserver> widget_observer( | 104 std::unique_ptr<WidgetClosingObserver> widget_observer( |
| 105 new WidgetClosingObserver(delegate->GetWidget())); | 105 new WidgetClosingObserver(delegate->GetWidget())); |
| 106 | 106 |
| 107 ui::EventDispatchDetails details = | 107 ui::EventDispatchDetails details = |
| 108 anchor_widget->GetNativeWindow()->GetHost()->event_processor()-> | 108 anchor_widget->GetNativeWindow()->GetHost()->event_processor()-> |
| 109 OnEventFromSource(event); | 109 OnEventFromSource(event); |
| 110 EXPECT_FALSE(details.dispatcher_destroyed); | 110 EXPECT_FALSE(details.dispatcher_destroyed); |
| 111 | 111 |
| 112 EXPECT_TRUE(widget_observer->widget_destroyed()); | 112 EXPECT_TRUE(widget_observer->widget_destroyed()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST_F(FirstRunBubbleTest, CreateAndClose) { | 115 TEST_F(FirstRunBubbleTest, CreateAndClose) { |
| 116 // Create the anchor and parent widgets. | 116 // Create the anchor and parent widgets. |
| 117 views::Widget::InitParams params = | 117 views::Widget::InitParams params = |
| 118 CreateParams(views::Widget::InitParams::TYPE_WINDOW); | 118 CreateParams(views::Widget::InitParams::TYPE_WINDOW); |
| 119 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 119 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 120 scoped_ptr<views::Widget> anchor_widget(new views::Widget); | 120 std::unique_ptr<views::Widget> anchor_widget(new views::Widget); |
| 121 anchor_widget->Init(params); | 121 anchor_widget->Init(params); |
| 122 anchor_widget->Show(); | 122 anchor_widget->Show(); |
| 123 | 123 |
| 124 FirstRunBubble* delegate = | 124 FirstRunBubble* delegate = |
| 125 FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView()); | 125 FirstRunBubble::ShowBubble(NULL, anchor_widget->GetContentsView()); |
| 126 EXPECT_TRUE(delegate != NULL); | 126 EXPECT_TRUE(delegate != NULL); |
| 127 delegate->GetWidget()->CloseNow(); | 127 delegate->GetWidget()->CloseNow(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Tests that the first run bubble is closed when keyboard events are | 130 // Tests that the first run bubble is closed when keyboard events are |
| (...skipping 10 matching lines...) Expand all Loading... |
| 141 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 141 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 142 CreateAndCloseBubbleOnEventTest(&mouse_down); | 142 CreateAndCloseBubbleOnEventTest(&mouse_down); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(FirstRunBubbleTest, CloseBubbleOnTouchDownEvent) { | 145 TEST_F(FirstRunBubbleTest, CloseBubbleOnTouchDownEvent) { |
| 146 ui::TouchEvent touch_down( | 146 ui::TouchEvent touch_down( |
| 147 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); | 147 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); |
| 148 CreateAndCloseBubbleOnEventTest(&touch_down); | 148 CreateAndCloseBubbleOnEventTest(&touch_down); |
| 149 } | 149 } |
| 150 | 150 |
| OLD | NEW |