| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/intent_picker_bubble_view.h" | 5 #include "chrome/browser/ui/views/intent_picker_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h" | 11 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h" |
| 12 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
| 16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/button/label_button.h" | |
| 18 #include "ui/views/controls/scroll_view.h" | 17 #include "ui/views/controls/scroll_view.h" |
| 19 #include "ui/views/resources/grit/views_resources.h" | 18 #include "ui/views/resources/grit/views_resources.h" |
| 20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 21 | 20 |
| 22 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon; | 21 using NameAndIcon = arc::ArcNavigationThrottle::NameAndIcon; |
| 23 using content::WebContents; | 22 using content::WebContents; |
| 24 using content::OpenURLParams; | 23 using content::OpenURLParams; |
| 25 using content::Referrer; | 24 using content::Referrer; |
| 26 | 25 |
| 27 class IntentPickerBubbleViewTest : public BrowserWithTestWindowTest { | 26 class IntentPickerBubbleViewTest : public BrowserWithTestWindowTest { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 72 |
| 74 private: | 73 private: |
| 75 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleViewTest); | 74 DISALLOW_COPY_AND_ASSIGN(IntentPickerBubbleViewTest); |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 // Verifies that we didn't set up an image for any LabelButton. | 77 // Verifies that we didn't set up an image for any LabelButton. |
| 79 TEST_F(IntentPickerBubbleViewTest, NullIcons) { | 78 TEST_F(IntentPickerBubbleViewTest, NullIcons) { |
| 80 CreateBubbleView(false); | 79 CreateBubbleView(false); |
| 81 size_t size = bubble_->app_info_.size(); | 80 size_t size = bubble_->app_info_.size(); |
| 82 for (size_t i = 0; i < size; ++i) { | 81 for (size_t i = 0; i < size; ++i) { |
| 83 views::LabelButton* app = bubble_->GetLabelButtonAt(i); | 82 gfx::ImageSkia image = bubble_->GetAppImageForTesting(i); |
| 84 EXPECT_TRUE( | 83 EXPECT_TRUE(image.isNull()) << i; |
| 85 app->GetImage(views::Button::ButtonState::STATE_NORMAL).isNull()) << i; | |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 | 86 |
| 89 // Verifies that all the icons contain a non-null icon. | 87 // Verifies that all the icons contain a non-null icon. |
| 90 TEST_F(IntentPickerBubbleViewTest, NonNullIcons) { | 88 TEST_F(IntentPickerBubbleViewTest, NonNullIcons) { |
| 91 CreateBubbleView(true); | 89 CreateBubbleView(true); |
| 92 size_t size = bubble_->app_info_.size(); | 90 size_t size = bubble_->app_info_.size(); |
| 93 for (size_t i = 0; i < size; ++i) { | 91 for (size_t i = 0; i < size; ++i) { |
| 94 views::LabelButton* app = bubble_->GetLabelButtonAt(i); | 92 gfx::ImageSkia image = bubble_->GetAppImageForTesting(i); |
| 95 EXPECT_FALSE( | 93 EXPECT_FALSE(image.isNull()) << i; |
| 96 app->GetImage(views::Button::ButtonState::STATE_NORMAL).isNull()) << i; | |
| 97 } | 94 } |
| 98 } | 95 } |
| 99 | 96 |
| 100 // Verifies that the bubble contains as many rows as the input. Populated the | 97 // Verifies that the bubble contains as many rows as the input. Populated the |
| 101 // bubble with an arbitrary image in every row. | 98 // bubble with an arbitrary image in every row. |
| 102 TEST_F(IntentPickerBubbleViewTest, LabelsPtrVectorSize) { | 99 TEST_F(IntentPickerBubbleViewTest, LabelsPtrVectorSize) { |
| 103 CreateBubbleView(true); | 100 CreateBubbleView(true); |
| 104 EXPECT_EQ(app_info_.size(), bubble_->app_info_.size()); | 101 EXPECT_EQ(app_info_.size(), bubble_->app_info_.size()); |
| 105 } | 102 } |
| OLD | NEW |