OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/translate/translate_bubble_view.h" | 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/ui/translate/translate_bubble_model.h" | 10 #include "chrome/browser/ui/translate/translate_bubble_model.h" |
9 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" | 11 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/views/controls/button/checkbox.h" | 13 #include "ui/views/controls/button/checkbox.h" |
12 #include "ui/views/controls/combobox/combobox.h" | 14 #include "ui/views/controls/combobox/combobox.h" |
13 #include "ui/views/test/combobox_test_api.h" | 15 #include "ui/views/test/combobox_test_api.h" |
14 #include "ui/views/test/views_test_base.h" | 16 #include "ui/views/test/views_test_base.h" |
15 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
16 | 18 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 138 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
137 | 139 |
138 anchor_widget_.reset(new views::Widget()); | 140 anchor_widget_.reset(new views::Widget()); |
139 anchor_widget_->Init(params); | 141 anchor_widget_->Init(params); |
140 anchor_widget_->Show(); | 142 anchor_widget_->Show(); |
141 | 143 |
142 mock_model_ = new MockTranslateBubbleModel( | 144 mock_model_ = new MockTranslateBubbleModel( |
143 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE); | 145 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE); |
144 scoped_ptr<TranslateBubbleModel> model(mock_model_); | 146 scoped_ptr<TranslateBubbleModel> model(mock_model_); |
145 bubble_ = new TranslateBubbleView(anchor_widget_->GetContentsView(), | 147 bubble_ = new TranslateBubbleView(anchor_widget_->GetContentsView(), |
146 model.Pass(), | 148 std::move(model), |
147 translate::TranslateErrors::NONE, | 149 translate::TranslateErrors::NONE, NULL); |
148 NULL); | |
149 views::BubbleDelegateView::CreateBubble(bubble_)->Show(); | 150 views::BubbleDelegateView::CreateBubble(bubble_)->Show(); |
150 } | 151 } |
151 | 152 |
152 void TearDown() override { | 153 void TearDown() override { |
153 bubble_->GetWidget()->CloseNow(); | 154 bubble_->GetWidget()->CloseNow(); |
154 anchor_widget_.reset(); | 155 anchor_widget_.reset(); |
155 | 156 |
156 views::ViewsTestBase::TearDown(); | 157 views::ViewsTestBase::TearDown(); |
157 } | 158 } |
158 | 159 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 354 |
354 TEST_F(TranslateBubbleViewTest, CancelButtonReturningError) { | 355 TEST_F(TranslateBubbleViewTest, CancelButtonReturningError) { |
355 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR); | 356 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR); |
356 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED); | 357 bubble_->SwitchView(TranslateBubbleModel::VIEW_STATE_ADVANCED); |
357 | 358 |
358 // Click the "Cancel" button to go back. | 359 // Click the "Cancel" button to go back. |
359 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ADVANCED, bubble_->GetViewState()); | 360 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ADVANCED, bubble_->GetViewState()); |
360 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL); | 361 bubble_->HandleButtonPressed(TranslateBubbleView::BUTTON_ID_CANCEL); |
361 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ERROR, bubble_->GetViewState()); | 362 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_ERROR, bubble_->GetViewState()); |
362 } | 363 } |
OLD | NEW |