Index: chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc |
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc b/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc |
index 6a78a695b09a82702533e12c60d54e8ae52b2b8d..ee99aa0002b3d5d724a0e14ac1339fc5eb0276d4 100644 |
--- a/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc |
+++ b/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc |
@@ -14,7 +14,6 @@ |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/image/image.h" |
#include "ui/views/controls/button/button.h" |
-#include "ui/views/controls/button/label_button.h" |
#include "ui/views/controls/scroll_view.h" |
#include "ui/views/resources/grit/views_resources.h" |
#include "url/gurl.h" |
@@ -24,6 +23,12 @@ using content::WebContents; |
using content::OpenURLParams; |
using content::Referrer; |
+class MousePressedEvent : public ui::Event { |
+ public: |
+ MousePressedEvent() : Event(ui::ET_MOUSE_PRESSED, base::TimeTicks(), 0) {} |
+ ~MousePressedEvent() override {} |
+}; |
+ |
class IntentPickerBubbleViewTest : public BrowserWithTestWindowTest { |
public: |
IntentPickerBubbleViewTest() = default; |
@@ -80,9 +85,8 @@ TEST_F(IntentPickerBubbleViewTest, NullIcons) { |
CreateBubbleView(false); |
size_t size = bubble_->app_info_.size(); |
for (size_t i = 0; i < size; ++i) { |
- views::LabelButton* app = bubble_->GetLabelButtonAt(i); |
- EXPECT_TRUE( |
- app->GetImage(views::Button::ButtonState::STATE_NORMAL).isNull()) << i; |
+ gfx::ImageSkia image = bubble_->GetAppImageForTesting(i); |
+ EXPECT_TRUE(image.isNull()) << i; |
} |
} |
@@ -91,9 +95,8 @@ TEST_F(IntentPickerBubbleViewTest, NonNullIcons) { |
CreateBubbleView(true); |
size_t size = bubble_->app_info_.size(); |
for (size_t i = 0; i < size; ++i) { |
- views::LabelButton* app = bubble_->GetLabelButtonAt(i); |
- EXPECT_FALSE( |
- app->GetImage(views::Button::ButtonState::STATE_NORMAL).isNull()) << i; |
+ gfx::ImageSkia image = bubble_->GetAppImageForTesting(i); |
+ EXPECT_FALSE(image.isNull()) << i; |
} |
} |
@@ -103,3 +106,40 @@ TEST_F(IntentPickerBubbleViewTest, LabelsPtrVectorSize) { |
CreateBubbleView(true); |
EXPECT_EQ(app_info_.size(), bubble_->app_info_.size()); |
} |
+ |
+// Verifies the InkDrop state when creating a new bubble. |
+TEST_F(IntentPickerBubbleViewTest, VerifyStartingInkDrop) { |
+ CreateBubbleView(true); |
+ size_t size = bubble_->app_info_.size(); |
+ for (size_t i = 0; i < size; ++i) { |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting(i), |
+ views::InkDropState::HIDDEN); |
+ } |
+} |
+ |
+// Press each button at a time and make sure it goes to ACTIVATED state, |
+// followed by HIDDEN state after selecting other button. |
+TEST_F(IntentPickerBubbleViewTest, InkDropStateTransition) { |
+ CreateBubbleView(true); |
+ size_t size = bubble_->app_info_.size(); |
+ for (size_t i = 0; i < size; ++i) { |
+ bubble_->PressButtonForTesting((i + 1) % size, MousePressedEvent()); |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting(i), |
+ views::InkDropState::HIDDEN); |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting((i + 1) % size), |
+ views::InkDropState::ACTIVATED); |
+ } |
+} |
+ |
+// Arbitrary press the first button twice, check that the InkDropState remains |
+// the same. |
+TEST_F(IntentPickerBubbleViewTest, PressButtonTwice) { |
+ CreateBubbleView(true); |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting(0), views::InkDropState::HIDDEN); |
+ bubble_->PressButtonForTesting(0, MousePressedEvent()); |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting(0), |
+ views::InkDropState::ACTIVATED); |
+ bubble_->PressButtonForTesting(0, MousePressedEvent()); |
+ EXPECT_EQ(bubble_->GetInkDropStateForTesting(0), |
+ views::InkDropState::ACTIVATED); |
+} |