OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" | 8 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" |
9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 9 #include "chrome/browser/extensions/extension_function_test_utils.h" |
10 #include "chrome/browser/extensions/extension_message_bubble.h" | 10 #include "chrome/browser/extensions/extension_message_bubble.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/settings_api_bubble_controller.h" | |
12 #include "chrome/browser/extensions/suspicious_extension_bubble_controller.h" | 13 #include "chrome/browser/extensions/suspicious_extension_bubble_controller.h" |
13 #include "chrome/browser/extensions/test_extension_system.h" | 14 #include "chrome/browser/extensions/test_extension_system.h" |
14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
17 #include "extensions/common/feature_switch.h" | 18 #include "extensions/common/feature_switch.h" |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
21 class TestDelegate { | 22 class TestDelegate { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 ++dismiss_button_callback_count_; | 91 ++dismiss_button_callback_count_; |
91 DevModeBubbleController::OnBubbleDismiss(); | 92 DevModeBubbleController::OnBubbleDismiss(); |
92 } | 93 } |
93 | 94 |
94 virtual void OnLinkClicked() OVERRIDE { | 95 virtual void OnLinkClicked() OVERRIDE { |
95 ++link_click_callback_count_; | 96 ++link_click_callback_count_; |
96 DevModeBubbleController::OnLinkClicked(); | 97 DevModeBubbleController::OnLinkClicked(); |
97 } | 98 } |
98 }; | 99 }; |
99 | 100 |
101 // A test class for the SettingsApiBubbleController. | |
102 class TestSettingsApiBubbleController | |
103 : public SettingsApiBubbleController, | |
104 public TestDelegate { | |
105 public: | |
106 TestSettingsApiBubbleController(Profile* profile, | |
107 SettingsApiOverrideType type) | |
108 : SettingsApiBubbleController(profile, type) { | |
109 } | |
110 | |
111 virtual void OnBubbleAction() OVERRIDE { | |
112 ++action_button_callback_count_; | |
113 SettingsApiBubbleController::OnBubbleAction(); | |
114 } | |
115 | |
116 virtual void OnBubbleDismiss() OVERRIDE { | |
117 ++dismiss_button_callback_count_; | |
118 SettingsApiBubbleController::OnBubbleDismiss(); | |
119 } | |
120 | |
121 virtual void OnLinkClicked() OVERRIDE { | |
122 ++link_click_callback_count_; | |
123 SettingsApiBubbleController::OnLinkClicked(); | |
124 } | |
125 }; | |
126 | |
100 // A fake bubble used for testing the controller. Takes an action that specifies | 127 // A fake bubble used for testing the controller. Takes an action that specifies |
101 // what should happen when the bubble is "shown" (the bubble is actually not | 128 // what should happen when the bubble is "shown" (the bubble is actually not |
102 // shown, the corresponding action is taken immediately). | 129 // shown, the corresponding action is taken immediately). |
103 class FakeExtensionMessageBubble : public ExtensionMessageBubble { | 130 class FakeExtensionMessageBubble : public ExtensionMessageBubble { |
104 public: | 131 public: |
105 enum ExtensionBubbleAction { | 132 enum ExtensionBubbleAction { |
106 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, | 133 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, |
107 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, | 134 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, |
108 BUBBLE_ACTION_CLICK_LINK, | 135 BUBBLE_ACTION_CLICK_LINK, |
109 }; | 136 }; |
(...skipping 28 matching lines...) Expand all Loading... | |
138 private: | 165 private: |
139 ExtensionBubbleAction action_; | 166 ExtensionBubbleAction action_; |
140 | 167 |
141 base::Closure action_callback_; | 168 base::Closure action_callback_; |
142 base::Closure dismiss_callback_; | 169 base::Closure dismiss_callback_; |
143 base::Closure link_callback_; | 170 base::Closure link_callback_; |
144 }; | 171 }; |
145 | 172 |
146 class ExtensionMessageBubbleTest : public testing::Test { | 173 class ExtensionMessageBubbleTest : public testing::Test { |
147 public: | 174 public: |
148 ExtensionMessageBubbleTest() { | 175 ExtensionMessageBubbleTest() {} |
176 | |
177 std::string LoadExtensionWithManifest(const std::string& manifest_template, | |
178 const std::string& index, | |
179 Manifest::Location location) { | |
180 std::string extension_data; | |
181 base::ReplaceChars(manifest_template, "#", index, &extension_data); | |
182 scoped_refptr<Extension> my_test_extension( | |
183 CreateExtension( | |
Yoyo Zhou
2014/04/02 20:36:26
Can you use ExtensionBuilder and DictionaryBuilder
| |
184 location, | |
185 extension_data, | |
186 std::string("Autogenerated ") + index)); | |
187 service_->AddExtension(my_test_extension); | |
188 return my_test_extension->id(); | |
189 } | |
190 | |
191 std::string LoadGenericExtension(const std::string& index, | |
192 Manifest::Location location) { | |
193 std::string manifest_template = | |
194 "{\"name\": \"Extension #\"," | |
195 "\"version\": \"1.0\"," | |
196 "\"manifest_version\": 2}"; | |
197 return LoadExtensionWithManifest(manifest_template, index, location); | |
198 } | |
199 | |
200 std::string LoadExtensionWithAction(const std::string& index, | |
201 Manifest::Location location) { | |
202 std::string manifest_template = | |
203 "{\"name\": \"Extension #\"," | |
204 "\"version\": \"1.0\"," | |
205 "\"browser_action\": {" | |
206 " \"default_title\": \"Default title\"" | |
207 "}," | |
208 "\"manifest_version\": 2}"; | |
209 return LoadExtensionWithManifest(manifest_template, index, location); | |
210 } | |
211 | |
212 std::string LoadExtensionOverridingHome(const std::string& index, | |
213 Manifest::Location location) { | |
214 std::string manifest_template = | |
215 "{\"name\": \"Extension #\"," | |
216 "\"version\": \"1.0\"," | |
217 "\"manifest_version\": 2," | |
218 "\"chrome_settings_overrides\": {" | |
219 "\"homepage\": \"http://www.google.com\"" | |
220 "}}"; | |
221 return LoadExtensionWithManifest(manifest_template, index, location); | |
222 } | |
223 | |
224 std::string LoadExtensionOverridingStart(const std::string& index, | |
225 Manifest::Location location) { | |
226 std::string manifest_template = | |
227 "{\"name\": \"Extension #\"," | |
228 "\"version\": \"1.0\"," | |
229 "\"manifest_version\": 2," | |
230 "\"chrome_settings_overrides\": {" | |
231 "\"startup_pages\": [\"http://www.google.com/\"]" | |
232 "}}"; | |
233 return LoadExtensionWithManifest(manifest_template, index, location); | |
234 } | |
235 | |
236 void Init() { | |
149 // The two lines of magical incantation required to get the extension | 237 // The two lines of magical incantation required to get the extension |
150 // service to work inside a unit test and access the extension prefs. | 238 // service to work inside a unit test and access the extension prefs. |
151 thread_bundle_.reset(new content::TestBrowserThreadBundle); | 239 thread_bundle_.reset(new content::TestBrowserThreadBundle); |
152 profile_.reset(new TestingProfile); | 240 profile_.reset(new TestingProfile); |
153 | |
154 static_cast<TestExtensionSystem*>( | 241 static_cast<TestExtensionSystem*>( |
155 ExtensionSystem::Get(profile()))->CreateExtensionService( | 242 ExtensionSystem::Get(profile()))->CreateExtensionService( |
156 CommandLine::ForCurrentProcess(), | 243 CommandLine::ForCurrentProcess(), |
157 base::FilePath(), | 244 base::FilePath(), |
158 false); | 245 false); |
159 service_ = profile_->GetExtensionService(); | 246 service_ = profile_->GetExtensionService(); |
160 service_->Init(); | 247 service_->Init(); |
248 } | |
161 | 249 |
162 std::string basic_extension = | |
163 "{\"name\": \"Extension #\"," | |
164 "\"version\": \"1.0\"," | |
165 "\"manifest_version\": 2}"; | |
166 std::string basic_extension_with_action = | |
167 "{\"name\": \"Extension #\"," | |
168 "\"version\": \"1.0\"," | |
169 "\"browser_action\": {" | |
170 " \"default_title\": \"Default title\"" | |
171 "}," | |
172 "\"manifest_version\": 2}"; | |
173 | |
174 std::string extension_data; | |
175 base::ReplaceChars(basic_extension_with_action, "#", "1", &extension_data); | |
176 scoped_refptr<Extension> my_test_extension1( | |
177 CreateExtension( | |
178 Manifest::COMMAND_LINE, | |
179 extension_data, | |
180 "Autogenerated 1")); | |
181 | |
182 base::ReplaceChars(basic_extension, "#", "2", &extension_data); | |
183 scoped_refptr<Extension> my_test_extension2( | |
184 CreateExtension( | |
185 Manifest::UNPACKED, | |
186 extension_data, | |
187 "Autogenerated 2")); | |
188 | |
189 base::ReplaceChars(basic_extension, "#", "3", &extension_data); | |
190 scoped_refptr<Extension> regular_extension( | |
191 CreateExtension( | |
192 Manifest::EXTERNAL_POLICY, | |
193 extension_data, | |
194 "Autogenerated 3")); | |
195 | |
196 extension_id1_ = my_test_extension1->id(); | |
197 extension_id2_ = my_test_extension2->id(); | |
198 extension_id3_ = regular_extension->id(); | |
199 | |
200 service_->AddExtension(regular_extension); | |
201 service_->AddExtension(my_test_extension1); | |
202 service_->AddExtension(my_test_extension2); | |
203 } | |
204 virtual ~ExtensionMessageBubbleTest() { | 250 virtual ~ExtensionMessageBubbleTest() { |
205 // Make sure the profile is destroyed before the thread bundle. | 251 // Make sure the profile is destroyed before the thread bundle. |
206 profile_.reset(NULL); | 252 profile_.reset(NULL); |
207 } | 253 } |
208 | 254 |
209 virtual void SetUp() { | 255 virtual void SetUp() { |
210 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 256 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
211 } | 257 } |
212 | 258 |
213 protected: | 259 protected: |
(...skipping 25 matching lines...) Expand all Loading... | |
239 }; | 285 }; |
240 | 286 |
241 // The feature this is meant to test is only implemented on Windows. | 287 // The feature this is meant to test is only implemented on Windows. |
242 #if defined(OS_WIN) | 288 #if defined(OS_WIN) |
243 #define MAYBE_WipeoutControllerTest WipeoutControllerTest | 289 #define MAYBE_WipeoutControllerTest WipeoutControllerTest |
244 #else | 290 #else |
245 #define MAYBE_WipeoutControllerTest DISABLED_WipeoutControllerTest | 291 #define MAYBE_WipeoutControllerTest DISABLED_WipeoutControllerTest |
246 #endif | 292 #endif |
247 | 293 |
248 TEST_F(ExtensionMessageBubbleTest, MAYBE_WipeoutControllerTest) { | 294 TEST_F(ExtensionMessageBubbleTest, MAYBE_WipeoutControllerTest) { |
249 // The test base class adds three extensions, and we control two of them in | 295 Init(); |
250 // this test (ids are: extension_id1_ and extension_id2_). | 296 // Add three extensions, and control two of them in this test (extension 1 |
297 // and 2). | |
298 extension_id1_ = LoadExtensionWithAction("1", Manifest::COMMAND_LINE); | |
299 extension_id2_ = LoadGenericExtension("2", Manifest::UNPACKED); | |
300 extension_id3_ = LoadGenericExtension("3", Manifest::EXTERNAL_POLICY); | |
301 | |
251 scoped_ptr<TestSuspiciousExtensionBubbleController> controller( | 302 scoped_ptr<TestSuspiciousExtensionBubbleController> controller( |
252 new TestSuspiciousExtensionBubbleController(profile())); | 303 new TestSuspiciousExtensionBubbleController(profile())); |
253 FakeExtensionMessageBubble bubble; | 304 FakeExtensionMessageBubble bubble; |
254 bubble.set_action_on_show( | 305 bubble.set_action_on_show( |
255 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); | 306 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); |
256 | 307 |
257 // Validate that we don't have a suppress value for the extensions. | 308 // Validate that we don't have a suppress value for the extensions. |
258 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 309 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
259 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); | 310 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); |
260 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_)); | 311 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 // The feature this is meant to test is only implemented on Windows. | 363 // The feature this is meant to test is only implemented on Windows. |
313 #if defined(OS_WIN) | 364 #if defined(OS_WIN) |
314 #define MAYBE_DevModeControllerTest DevModeControllerTest | 365 #define MAYBE_DevModeControllerTest DevModeControllerTest |
315 #else | 366 #else |
316 #define MAYBE_DevModeControllerTest DISABLED_DevModeControllerTest | 367 #define MAYBE_DevModeControllerTest DISABLED_DevModeControllerTest |
317 #endif | 368 #endif |
318 | 369 |
319 TEST_F(ExtensionMessageBubbleTest, MAYBE_DevModeControllerTest) { | 370 TEST_F(ExtensionMessageBubbleTest, MAYBE_DevModeControllerTest) { |
320 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( | 371 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( |
321 FeatureSwitch::force_dev_mode_highlighting(), true); | 372 FeatureSwitch::force_dev_mode_highlighting(), true); |
322 // The test base class adds three extensions, and we control two of them in | 373 Init(); |
323 // this test (ids are: extension_id1_ and extension_id2_). Extension 1 is a | 374 // Add three extensions, and control two of them in this test (extension 1 |
324 // regular extension, Extension 2 is UNPACKED so it counts as a DevMode | 375 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it |
325 // extension. | 376 // counts as a DevMode extension. |
377 extension_id1_ = LoadExtensionWithAction("1", Manifest::COMMAND_LINE); | |
378 extension_id2_ = LoadGenericExtension("2", Manifest::UNPACKED); | |
379 extension_id3_ = LoadGenericExtension("3", Manifest::EXTERNAL_POLICY); | |
380 | |
326 scoped_ptr<TestDevModeBubbleController> controller( | 381 scoped_ptr<TestDevModeBubbleController> controller( |
327 new TestDevModeBubbleController(profile())); | 382 new TestDevModeBubbleController(profile())); |
328 | 383 |
329 // The list will contain one enabled unpacked extension. | 384 // The list will contain one enabled unpacked extension. |
330 EXPECT_TRUE(controller->ShouldShow()); | 385 EXPECT_TRUE(controller->ShouldShow()); |
331 std::vector<base::string16> dev_mode_extensions = | 386 std::vector<base::string16> dev_mode_extensions = |
332 controller->GetExtensionList(); | 387 controller->GetExtensionList(); |
333 ASSERT_EQ(2U, dev_mode_extensions.size()); | 388 ASSERT_EQ(2U, dev_mode_extensions.size()); |
334 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); | 389 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); |
335 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); | 390 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 service_->DisableExtension(extension_id2_, Extension::DISABLE_USER_ACTION); | 444 service_->DisableExtension(extension_id2_, Extension::DISABLE_USER_ACTION); |
390 | 445 |
391 controller.reset(new TestDevModeBubbleController( | 446 controller.reset(new TestDevModeBubbleController( |
392 profile())); | 447 profile())); |
393 DevModeBubbleController::ClearProfileListForTesting(); | 448 DevModeBubbleController::ClearProfileListForTesting(); |
394 EXPECT_FALSE(controller->ShouldShow()); | 449 EXPECT_FALSE(controller->ShouldShow()); |
395 dev_mode_extensions = controller->GetExtensionList(); | 450 dev_mode_extensions = controller->GetExtensionList(); |
396 EXPECT_EQ(0U, dev_mode_extensions.size()); | 451 EXPECT_EQ(0U, dev_mode_extensions.size()); |
397 } | 452 } |
398 | 453 |
454 // The feature this is meant to test is only implemented on Windows. | |
455 #if defined(OS_WIN) | |
456 #define MAYBE_SettingsApiControllerTest SettingsApiControllerTest | |
457 #else | |
458 #define MAYBE_SettingsApiControllerTest DISABLED_SettingsApiControllerTest | |
459 #endif | |
460 | |
461 TEST_F(ExtensionMessageBubbleTest, MAYBE_SettingsApiControllerTest) { | |
462 Init(); | |
463 extensions::ExtensionPrefs* prefs = | |
464 extensions::ExtensionPrefs::Get(profile()); | |
465 | |
466 // We deliberately skip testing the search engine since it relies on | |
Yoyo Zhou
2014/04/02 20:36:26
IMHO this would be easier to read if
- the for loo
| |
467 // TemplateURLServiceFactory that isn't available while unit testing. This | |
468 // test is only simulating the bubble interaction with the user and that is | |
469 // more or less the same for the search engine as it is for the others. | |
470 for (int i = 0; i < 3; i += 2) { | |
471 switch (static_cast<SettingsApiOverrideType>(i)) { | |
472 case BUBBLE_TYPE_HOME_PAGE: | |
473 // Load two extensions overriding home page and one overriding something | |
474 // unrelated (to check for interference). Extension 2 should still win | |
475 // on the home page setting. | |
476 extension_id1_ = LoadExtensionOverridingHome("1", Manifest::UNPACKED); | |
477 extension_id2_ = LoadExtensionOverridingHome("2", Manifest::UNPACKED); | |
478 extension_id3_ = LoadExtensionOverridingStart("3", Manifest::UNPACKED); | |
479 break; | |
480 case BUBBLE_TYPE_STARTUP_PAGES: | |
481 // Load two extensions overriding start page and one overriding | |
482 // something unrelated (to check for interference). Extension 2 should | |
483 // still win on the startup page setting. | |
484 extension_id1_ = LoadExtensionOverridingStart("1", Manifest::UNPACKED); | |
485 extension_id2_ = LoadExtensionOverridingStart("2", Manifest::UNPACKED); | |
486 extension_id3_ = LoadExtensionOverridingHome("3", Manifest::UNPACKED); | |
487 break; | |
488 default: | |
489 NOTREACHED(); | |
490 break; | |
491 } | |
492 | |
493 scoped_ptr<TestSettingsApiBubbleController> controller( | |
494 new TestSettingsApiBubbleController( | |
495 profile(), static_cast<SettingsApiOverrideType>(i))); | |
496 | |
497 // The list will contain one enabled unpacked extension (ext 2). | |
498 EXPECT_TRUE(controller->ShouldShow(extension_id2_)); | |
499 std::vector<base::string16> override_extensions = | |
500 controller->GetExtensionList(); | |
501 ASSERT_EQ(1U, override_extensions.size()); | |
502 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == | |
503 override_extensions[0].c_str()); | |
504 EXPECT_EQ(0U, controller->link_click_count()); | |
505 EXPECT_EQ(0U, controller->dismiss_click_count()); | |
506 EXPECT_EQ(0U, controller->action_click_count()); | |
507 | |
508 // Simulate showing the bubble and dismissing it. | |
509 FakeExtensionMessageBubble bubble; | |
510 bubble.set_action_on_show( | |
511 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); | |
512 controller->Show(&bubble); | |
513 EXPECT_EQ(0U, controller->link_click_count()); | |
514 EXPECT_EQ(0U, controller->action_click_count()); | |
515 EXPECT_EQ(1U, controller->dismiss_click_count()); | |
516 // No extension should have become disabled. | |
517 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL); | |
518 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL); | |
519 EXPECT_TRUE(service_->GetExtensionById(extension_id3_, false) != NULL); | |
520 // Only extension 2 should have been acknowledged. | |
521 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id1_)); | |
522 EXPECT_TRUE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id2_)); | |
523 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id3_)); | |
524 // Clean up after ourselves. | |
525 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id2_, false); | |
526 | |
527 // Simulate clicking the learn more link to dismiss it. | |
528 bubble.set_action_on_show( | |
529 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | |
530 controller.reset(new TestSettingsApiBubbleController( | |
531 profile(), static_cast<SettingsApiOverrideType>(i))); | |
532 controller->Show(&bubble); | |
533 EXPECT_EQ(1U, controller->link_click_count()); | |
534 EXPECT_EQ(0U, controller->action_click_count()); | |
535 EXPECT_EQ(0U, controller->dismiss_click_count()); | |
536 // No extension should have become disabled. | |
537 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL); | |
538 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL); | |
539 EXPECT_TRUE(service_->GetExtensionById(extension_id3_, false) != NULL); | |
540 // Only extension 2 should have been acknowledged. | |
541 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id1_)); | |
542 EXPECT_TRUE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id2_)); | |
543 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id3_)); | |
544 // Clean up after ourselves. | |
545 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id2_, false); | |
546 | |
547 // Do it again, but now opt to disable the extension. | |
548 bubble.set_action_on_show( | |
549 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | |
550 controller.reset(new TestSettingsApiBubbleController( | |
551 profile(), static_cast<SettingsApiOverrideType>(i))); | |
552 EXPECT_TRUE(controller->ShouldShow(extension_id2_)); | |
553 override_extensions = controller->GetExtensionList(); | |
554 EXPECT_EQ(1U, override_extensions.size()); | |
555 controller->Show(&bubble); // Simulate showing the bubble. | |
556 EXPECT_EQ(0U, controller->link_click_count()); | |
557 EXPECT_EQ(1U, controller->action_click_count()); | |
558 EXPECT_EQ(0U, controller->dismiss_click_count()); | |
559 // Only extension 2 should have become disabled. | |
560 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL); | |
561 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) == NULL); | |
562 EXPECT_TRUE(service_->GetExtensionById(extension_id3_, false) != NULL); | |
563 // No extension should have been acknowledged (it got disabled). | |
564 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id1_)); | |
565 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id2_)); | |
566 EXPECT_FALSE(prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id3_)); | |
567 | |
568 // Clean up after ourselves. | |
569 service_->UninstallExtension(extension_id1_, false, NULL); | |
570 service_->UninstallExtension(extension_id2_, false, NULL); | |
571 service_->UninstallExtension(extension_id3_, false, NULL); | |
572 } | |
573 } | |
574 | |
399 } // namespace extensions | 575 } // namespace extensions |
OLD | NEW |