| 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 17 matching lines...) Expand all Loading... |
| 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, | 36 MOCK_METHOD2(OnExtensionIconChanged, |
| 37 void(WebIntentPickerModel* model, const string16& extension_id)); | 37 void(WebIntentPickerModel* model, const string16& extension_id)); |
| 38 MOCK_METHOD1(OnInlineDisposition, void(WebIntentPickerModel* model)); | 38 MOCK_METHOD2(OnInlineDisposition, |
| 39 void(WebIntentPickerModel* model, const GURL& url)); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 class WebIntentPickerModelTest : public testing::Test { | 42 class WebIntentPickerModelTest : public testing::Test { |
| 42 public: | 43 public: |
| 43 WebIntentPickerModelTest() {} | 44 WebIntentPickerModelTest() {} |
| 44 | 45 |
| 45 virtual void SetUp() { | 46 virtual void SetUp() { |
| 46 testing::Test::SetUp(); | 47 testing::Test::SetUp(); |
| 47 model_.set_observer(&observer_); | 48 model_.set_observer(&observer_); |
| 48 } | 49 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 model_.SetSuggestedExtensionIconWithId(kId2, image); | 149 model_.SetSuggestedExtensionIconWithId(kId2, image); |
| 149 | 150 |
| 150 EXPECT_FALSE(gfx::test::IsEqual( | 151 EXPECT_FALSE(gfx::test::IsEqual( |
| 151 image, model_.GetSuggestedExtensionAt(0).icon)); | 152 image, model_.GetSuggestedExtensionAt(0).icon)); |
| 152 EXPECT_TRUE(gfx::test::IsEqual( | 153 EXPECT_TRUE(gfx::test::IsEqual( |
| 153 image, model_.GetSuggestedExtensionAt(1).icon)); | 154 image, model_.GetSuggestedExtensionAt(1).icon)); |
| 154 } | 155 } |
| 155 | 156 |
| 156 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { | 157 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { |
| 157 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); | 158 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); |
| 158 EXPECT_CALL(observer_, OnInlineDisposition(&model_)).Times(1); | 159 EXPECT_CALL(observer_, OnInlineDisposition(&model_, testing::_)).Times(1); |
| 159 | 160 |
| 160 EXPECT_FALSE(model_.IsInlineDisposition()); | 161 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 161 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); | 162 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); |
| 162 | 163 |
| 163 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); | 164 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); |
| 164 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); | 165 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); |
| 165 model_.SetInlineDisposition(1); | 166 model_.SetInlineDisposition(kUrl2); |
| 166 | 167 |
| 167 EXPECT_TRUE(model_.IsInlineDisposition()); | 168 EXPECT_TRUE(model_.IsInlineDisposition()); |
| 168 EXPECT_EQ(1U, model_.inline_disposition_index()); | 169 EXPECT_EQ(kUrl2, model_.inline_disposition_url()); |
| 169 | 170 |
| 170 model_.Clear(); | 171 model_.Clear(); |
| 171 | 172 |
| 172 EXPECT_FALSE(model_.IsInlineDisposition()); | 173 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 173 EXPECT_EQ(std::string::npos, model_.inline_disposition_index()); | 174 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); |
| 174 } | 175 } |
| OLD | NEW |