| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 EXPECT_EQ(3U, model_.GetInstalledServiceCount()); | 104 EXPECT_EQ(3U, model_.GetInstalledServiceCount()); |
| 105 | 105 |
| 106 model_.RemoveInstalledServiceAt(1); | 106 model_.RemoveInstalledServiceAt(1); |
| 107 | 107 |
| 108 EXPECT_EQ(2U, model_.GetInstalledServiceCount()); | 108 EXPECT_EQ(2U, model_.GetInstalledServiceCount()); |
| 109 EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url); | 109 EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url); |
| 110 EXPECT_EQ(kUrl3, model_.GetInstalledServiceAt(1).url); | 110 EXPECT_EQ(kUrl3, model_.GetInstalledServiceAt(1).url); |
| 111 } | 111 } |
| 112 | 112 |
| 113 TEST_F(WebIntentPickerModelTest, Clear) { | 113 TEST_F(WebIntentPickerModelTest, Clear) { |
| 114 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); | 114 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3)); |
| 115 | 115 |
| 116 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); | 116 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); |
| 117 model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition); | 117 model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition); |
| 118 | 118 |
| 119 EXPECT_EQ(2U, model_.GetInstalledServiceCount()); | 119 EXPECT_EQ(2U, model_.GetInstalledServiceCount()); |
| 120 | 120 |
| 121 model_.Clear(); | 121 model_.Clear(); |
| 122 | 122 |
| 123 EXPECT_EQ(0U, model_.GetInstalledServiceCount()); | 123 EXPECT_EQ(0U, model_.GetInstalledServiceCount()); |
| 124 } | 124 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 gfx::Image image(gfx::test::CreateImage()); | 196 gfx::Image image(gfx::test::CreateImage()); |
| 197 model_.SetSuggestedExtensionIconWithId(kId2, image); | 197 model_.SetSuggestedExtensionIconWithId(kId2, image); |
| 198 | 198 |
| 199 EXPECT_FALSE(gfx::test::IsEqual( | 199 EXPECT_FALSE(gfx::test::IsEqual( |
| 200 image, model_.GetSuggestedExtensionAt(0).icon)); | 200 image, model_.GetSuggestedExtensionAt(0).icon)); |
| 201 EXPECT_TRUE(gfx::test::IsEqual( | 201 EXPECT_TRUE(gfx::test::IsEqual( |
| 202 image, model_.GetSuggestedExtensionAt(1).icon)); | 202 image, model_.GetSuggestedExtensionAt(1).icon)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { | 205 TEST_F(WebIntentPickerModelTest, SetInlineDisposition) { |
| 206 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3); | 206 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3)); |
| 207 EXPECT_CALL(observer_, OnInlineDisposition(kTitle2, testing::_)).Times(1); | 207 EXPECT_CALL(observer_, OnInlineDisposition(kTitle2, testing::_)).Times(1); |
| 208 | 208 |
| 209 EXPECT_FALSE(model_.IsInlineDisposition()); | 209 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 210 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); | 210 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); |
| 211 | 211 |
| 212 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); | 212 model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition); |
| 213 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); | 213 model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition); |
| 214 model_.SetInlineDisposition(kUrl2); | 214 model_.SetInlineDisposition(kUrl2); |
| 215 | 215 |
| 216 EXPECT_TRUE(model_.IsInlineDisposition()); | 216 EXPECT_TRUE(model_.IsInlineDisposition()); |
| 217 EXPECT_EQ(kUrl2, model_.inline_disposition_url()); | 217 EXPECT_EQ(kUrl2, model_.inline_disposition_url()); |
| 218 | 218 |
| 219 model_.Clear(); | 219 model_.Clear(); |
| 220 EXPECT_FALSE(model_.IsInlineDisposition()); | 220 EXPECT_FALSE(model_.IsInlineDisposition()); |
| 221 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); | 221 EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 | 224 |
| 225 TEST_F(WebIntentPickerModelTest, WaitingForSuggestions) { | 225 TEST_F(WebIntentPickerModelTest, WaitingForSuggestions) { |
| 226 // Default status is that "waiting for suggestions". | 226 // Default status is that "waiting for suggestions". |
| 227 EXPECT_TRUE(model_.IsWaitingForSuggestions()); | 227 EXPECT_TRUE(model_.IsWaitingForSuggestions()); |
| 228 | 228 |
| 229 // "waiting" status can be toggled manually. | 229 // "waiting" status can be toggled manually. |
| 230 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2); | 230 EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2); |
| 231 model_.SetWaitingForSuggestions(false); | 231 model_.SetWaitingForSuggestions(false); |
| 232 EXPECT_FALSE(model_.IsWaitingForSuggestions()); | 232 EXPECT_FALSE(model_.IsWaitingForSuggestions()); |
| 233 model_.SetWaitingForSuggestions(true); | 233 model_.SetWaitingForSuggestions(true); |
| 234 EXPECT_TRUE(model_.IsWaitingForSuggestions()); | 234 EXPECT_TRUE(model_.IsWaitingForSuggestions()); |
| 235 } | 235 } |
| OLD | NEW |