| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | 6 #include "chrome/browser/ui/intents/web_intent_picker_model.h" |
| 7 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" | 7 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const WebIntentPickerModel::Disposition kInlineDisposition( | 26 const WebIntentPickerModel::Disposition kInlineDisposition( |
| 27 WebIntentPickerModel::DISPOSITION_INLINE); | 27 WebIntentPickerModel::DISPOSITION_INLINE); |
| 28 | 28 |
| 29 } | 29 } |
| 30 | 30 |
| 31 class WebIntentPickerModelObserverMock : public WebIntentPickerModelObserver { | 31 class WebIntentPickerModelObserverMock : public WebIntentPickerModelObserver { |
| 32 public: | 32 public: |
| 33 MOCK_METHOD1(OnModelChanged, void(WebIntentPickerModel* model)); | 33 MOCK_METHOD1(OnModelChanged, void(WebIntentPickerModel* model)); |
| 34 MOCK_METHOD2(OnFaviconChanged, | 34 MOCK_METHOD2(OnFaviconChanged, |
| 35 void(WebIntentPickerModel* model, size_t index)); | 35 void(WebIntentPickerModel* model, size_t index)); |
| 36 MOCK_METHOD2(OnExtensionIconChanged, |
| 37 void(WebIntentPickerModel* model, const string16& extension_id)); |
| 36 MOCK_METHOD1(OnInlineDisposition, void(WebIntentPickerModel* model)); | 38 MOCK_METHOD1(OnInlineDisposition, void(WebIntentPickerModel* model)); |
| 37 }; | 39 }; |
| 38 | 40 |
| 39 class WebIntentPickerModelTest : public testing::Test { | 41 class WebIntentPickerModelTest : public testing::Test { |
| 40 public: | 42 public: |
| 41 WebIntentPickerModelTest() {} | 43 WebIntentPickerModelTest() {} |
| 42 | 44 |
| 43 virtual void SetUp() { | 45 virtual void SetUp() { |
| 44 testing::Test::SetUp(); | 46 testing::Test::SetUp(); |
| 45 model_.set_observer(&observer_); | 47 model_.set_observer(&observer_); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 130 |
| 129 EXPECT_EQ(3U, model_.GetSuggestedExtensionCount()); | 131 EXPECT_EQ(3U, model_.GetSuggestedExtensionCount()); |
| 130 | 132 |
| 131 model_.RemoveSuggestedExtensionAt(1); | 133 model_.RemoveSuggestedExtensionAt(1); |
| 132 | 134 |
| 133 EXPECT_EQ(2U, model_.GetSuggestedExtensionCount()); | 135 EXPECT_EQ(2U, model_.GetSuggestedExtensionCount()); |
| 134 EXPECT_EQ(kId1, model_.GetSuggestedExtensionAt(0).id); | 136 EXPECT_EQ(kId1, model_.GetSuggestedExtensionAt(0).id); |
| 135 EXPECT_EQ(kId3, model_.GetSuggestedExtensionAt(1).id); | 137 EXPECT_EQ(kId3, model_.GetSuggestedExtensionAt(1).id); |
| 136 } | 138 } |
| 137 | 139 |
| 140 TEST_F(WebIntentPickerModelTest, SetSuggestedExtensionIconWithId) { |
| 141 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2); |
| 142 EXPECT_CALL(observer_, OnExtensionIconChanged(&model_, kId2)).Times(1); |
| 143 |
| 144 model_.AddSuggestedExtension(kTitle1, kId1, 3.0); |
| 145 model_.AddSuggestedExtension(kTitle2, kId2, 4.3); |
| 146 |
| 147 gfx::Image image(gfx::test::CreateImage()); |
| 148 model_.SetSuggestedExtensionIconWithId(kId2, image); |
| 149 |
| 150 EXPECT_FALSE(gfx::test::IsEqual( |
| 151 image, model_.GetSuggestedExtensionAt(0).icon)); |
| 152 EXPECT_TRUE(gfx::test::IsEqual( |
| 153 image, model_.GetSuggestedExtensionAt(1).icon)); |
| 154 } |
| 155 |
| 138 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { | 156 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { |
| 139 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); | 157 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); |
| 140 EXPECT_CALL(observer_, OnInlineDisposition(&model_)).Times(1); | 158 EXPECT_CALL(observer_, OnInlineDisposition(&model_)).Times(1); |
| 141 | 159 |
| 142 EXPECT_FALSE(model_.IsInlineDisposition()); | 160 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 143 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); | 161 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); |
| 144 | 162 |
| 145 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); | 163 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); |
| 146 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); | 164 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); |
| 147 model_.SetInlineDisposition(1); | 165 model_.SetInlineDisposition(1); |
| 148 | 166 |
| 149 EXPECT_TRUE(model_.IsInlineDisposition()); | 167 EXPECT_TRUE(model_.IsInlineDisposition()); |
| 150 EXPECT_EQ(1U, model_.inline_disposition_index()); | 168 EXPECT_EQ(1U, model_.inline_disposition_index()); |
| 151 | 169 |
| 152 model_.Clear(); | 170 model_.Clear(); |
| 153 | 171 |
| 154 EXPECT_FALSE(model_.IsInlineDisposition()); | 172 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 155 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); | 173 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); |
| 156 } | 174 } |
| OLD | NEW |