| 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 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/app/vector_icons/vector_icons.h" |
| 13 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" | 14 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h" | 15 #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h" |
| 15 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa.h" | 16 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa.h" |
| 16 #include "chrome/browser/ui/cocoa/spinner_view.h" | 17 #include "chrome/browser/ui/cocoa/spinner_view.h" |
| 17 #import "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 18 #import "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
| 18 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" | 19 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "skia/ext/skia_utils_mac.h" | 21 #include "skia/ext/skia_utils_mac.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "testing/gtest_mac.h" | 24 #include "testing/gtest_mac.h" |
| 24 #include "ui/base/l10n/l10n_util_mac.h" | 25 #include "ui/base/l10n/l10n_util_mac.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/color_palette.h" | 27 #include "ui/gfx/color_palette.h" |
| 27 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
| 28 #include "ui/gfx/image/image_unittest_util.h" | 29 #include "ui/gfx/image/image_unittest_util.h" |
| 29 #include "ui/gfx/paint_vector_icon.h" | 30 #include "ui/gfx/paint_vector_icon.h" |
| 30 #include "ui/gfx/vector_icons_public.h" | |
| 31 #include "ui/resources/grit/ui_resources.h" | 31 #include "ui/resources/grit/ui_resources.h" |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // The lookup table for signal strength level image. | 35 // The lookup table for signal strength level image. |
| 36 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, | 36 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, |
| 37 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, | 37 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, |
| 38 IDR_SIGNAL_4_BAR}; | 38 IDR_SIGNAL_4_BAR}; |
| 39 const int kSignalStrengthLevelImageSelectedIds[5] = { | 39 const int kSignalStrengthLevelImageSelectedIds[5] = { |
| 40 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, | 40 IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 : kSignalStrengthLevelImageSelectedIds | 111 : kSignalStrengthLevelImageSelectedIds |
| 112 [expected_signal_strength_level]; | 112 [expected_signal_strength_level]; |
| 113 EXPECT_NSEQ(rb_.GetNativeImageNamed(image_id).ToNSImage(), | 113 EXPECT_NSEQ(rb_.GetNativeImageNamed(image_id).ToNSImage(), |
| 114 [image_view image]); | 114 [image_view image]); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ExpectRowImageIsConnectedImage(int row, SkColor expected_color) { | 117 void ExpectRowImageIsConnectedImage(int row, SkColor expected_color) { |
| 118 NSImageView* image_view = [device_chooser_content_view_ | 118 NSImageView* image_view = [device_chooser_content_view_ |
| 119 tableRowViewImage:static_cast<NSInteger>(row)]; | 119 tableRowViewImage:static_cast<NSInteger>(row)]; |
| 120 ASSERT_TRUE(image_view); | 120 ASSERT_TRUE(image_view); |
| 121 EXPECT_TRUE(gfx::test::AreImagesEqual( | 121 EXPECT_TRUE( |
| 122 gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BLUETOOTH_CONNECTED, | 122 gfx::test::AreImagesEqual(gfx::Image(gfx::CreateVectorIcon( |
| 123 expected_color)), | 123 kBluetoothConnectedIcon, expected_color)), |
| 124 gfx::Image([[image_view image] copy]))); | 124 gfx::Image([[image_view image] copy]))); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ExpectRowTextIs(int row, NSString* expected_text) { | 127 void ExpectRowTextIs(int row, NSString* expected_text) { |
| 128 EXPECT_NSEQ(expected_text, | 128 EXPECT_NSEQ(expected_text, |
| 129 [[device_chooser_content_view_ | 129 [[device_chooser_content_view_ |
| 130 tableRowViewText:static_cast<NSInteger>(row)] stringValue]); | 130 tableRowViewText:static_cast<NSInteger>(row)] stringValue]); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void ExpectRowTextColorIs(int row, NSColor* expected_color) { | 133 void ExpectRowTextColorIs(int row, NSColor* expected_color) { |
| 134 EXPECT_NSEQ(expected_color, | 134 EXPECT_NSEQ(expected_color, |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 MockChooserController::ConnectedPairedStatus::NONE); | 1222 MockChooserController::ConnectedPairedStatus::NONE); |
| 1223 | 1223 |
| 1224 // Select option 0 and press "Get help" button. | 1224 // Select option 0 and press "Get help" button. |
| 1225 [table_view_ selectRowIndexes:[NSIndexSet indexSetWithIndex:0] | 1225 [table_view_ selectRowIndexes:[NSIndexSet indexSetWithIndex:0] |
| 1226 byExtendingSelection:NO]; | 1226 byExtendingSelection:NO]; |
| 1227 EXPECT_CALL(*mock_chooser_controller_, Select(testing::_)).Times(0); | 1227 EXPECT_CALL(*mock_chooser_controller_, Select(testing::_)).Times(0); |
| 1228 EXPECT_CALL(*mock_chooser_controller_, Cancel()).Times(0); | 1228 EXPECT_CALL(*mock_chooser_controller_, Cancel()).Times(0); |
| 1229 EXPECT_CALL(*mock_chooser_controller_, OpenHelpCenterUrl()).Times(1); | 1229 EXPECT_CALL(*mock_chooser_controller_, OpenHelpCenterUrl()).Times(1); |
| 1230 [help_button_ performClick:chooser_dialog_controller_]; | 1230 [help_button_ performClick:chooser_dialog_controller_]; |
| 1231 } | 1231 } |
| OLD | NEW |