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

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

Issue 2229943003: Reusing Ok/Cancel buttons for intent picker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For testing we don't create a widget to contain the class, so DialogButtons are not in place, this … Created 4 years, 3 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/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..07c612d62dd4981bb21ad3bb9251c4982c36b6d9 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,27 @@ 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);
+ }
+}
bruthig 2016/09/08 15:13:12 nit: It might be worth a test that clicks the same
djacobo_ 2016/09/08 21:27:06 Done.

Powered by Google App Engine
This is Rietveld 408576698