Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/extensions/extension_message_bubble_controller_unittest.cc

Issue 134103002: Refactor the extension message bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 EXPECT_EQ(0U, controller->dismiss_click_count()); 267 EXPECT_EQ(0U, controller->dismiss_click_count());
268 268
269 // Now disable an extension, specifying the wipeout flag. 269 // Now disable an extension, specifying the wipeout flag.
270 service_->DisableExtension(extension_id1_, 270 service_->DisableExtension(extension_id1_,
271 Extension::DISABLE_NOT_VERIFIED); 271 Extension::DISABLE_NOT_VERIFIED);
272 272
273 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); 273 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_));
274 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_)); 274 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_));
275 controller.reset(new TestSuspiciousExtensionBubbleController( 275 controller.reset(new TestSuspiciousExtensionBubbleController(
276 profile())); 276 profile()));
277 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
277 EXPECT_TRUE(controller->ShouldShow()); 278 EXPECT_TRUE(controller->ShouldShow());
278 suspicious_extensions = controller->GetExtensionList(); 279 suspicious_extensions = controller->GetExtensionList();
279 ASSERT_EQ(1U, suspicious_extensions.size()); 280 ASSERT_EQ(1U, suspicious_extensions.size());
280 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); 281 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]);
281 controller->Show(&bubble); // Simulate showing the bubble. 282 controller->Show(&bubble); // Simulate showing the bubble.
282 EXPECT_EQ(0U, controller->link_click_count()); 283 EXPECT_EQ(0U, controller->link_click_count());
283 EXPECT_EQ(1U, controller->dismiss_click_count()); 284 EXPECT_EQ(1U, controller->dismiss_click_count());
284 // Now the acknowledge flag should be set only for the first extension. 285 // Now the acknowledge flag should be set only for the first extension.
285 EXPECT_TRUE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); 286 EXPECT_TRUE(prefs->HasWipeoutBeenAcknowledged(extension_id1_));
286 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_)); 287 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id2_));
287 // Clear the flag. 288 // Clear the flag.
288 prefs->SetWipeoutAcknowledged(extension_id1_, false); 289 prefs->SetWipeoutAcknowledged(extension_id1_, false);
289 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); 290 EXPECT_FALSE(prefs->HasWipeoutBeenAcknowledged(extension_id1_));
290 291
291 // Now disable the other extension and exercise the link click code path. 292 // Now disable the other extension and exercise the link click code path.
292 service_->DisableExtension(extension_id2_, 293 service_->DisableExtension(extension_id2_,
293 Extension::DISABLE_NOT_VERIFIED); 294 Extension::DISABLE_NOT_VERIFIED);
294 295
295 bubble.set_action_on_show( 296 bubble.set_action_on_show(
296 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 297 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
297 controller.reset(new TestSuspiciousExtensionBubbleController( 298 controller.reset(new TestSuspiciousExtensionBubbleController(
298 profile())); 299 profile()));
300 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
299 EXPECT_TRUE(controller->ShouldShow()); 301 EXPECT_TRUE(controller->ShouldShow());
300 suspicious_extensions = controller->GetExtensionList(); 302 suspicious_extensions = controller->GetExtensionList();
301 ASSERT_EQ(2U, suspicious_extensions.size()); 303 ASSERT_EQ(2U, suspicious_extensions.size());
302 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); 304 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]);
303 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); 305 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]);
304 controller->Show(&bubble); // Simulate showing the bubble. 306 controller->Show(&bubble); // Simulate showing the bubble.
305 EXPECT_EQ(1U, controller->link_click_count()); 307 EXPECT_EQ(1U, controller->link_click_count());
306 EXPECT_EQ(0U, controller->dismiss_click_count()); 308 EXPECT_EQ(0U, controller->dismiss_click_count());
307 EXPECT_TRUE(prefs->HasWipeoutBeenAcknowledged(extension_id1_)); 309 EXPECT_TRUE(prefs->HasWipeoutBeenAcknowledged(extension_id1_));
308 } 310 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 EXPECT_EQ(0U, controller->action_click_count()); 346 EXPECT_EQ(0U, controller->action_click_count());
345 EXPECT_EQ(1U, controller->dismiss_click_count()); 347 EXPECT_EQ(1U, controller->dismiss_click_count());
346 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL); 348 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL);
347 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL); 349 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL);
348 350
349 // Do it again, but now press different button (Disable). 351 // Do it again, but now press different button (Disable).
350 bubble.set_action_on_show( 352 bubble.set_action_on_show(
351 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 353 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
352 controller.reset(new TestDevModeBubbleController( 354 controller.reset(new TestDevModeBubbleController(
353 profile())); 355 profile()));
356 DevModeBubbleController::ClearProfileListForTesting();
354 EXPECT_TRUE(controller->ShouldShow()); 357 EXPECT_TRUE(controller->ShouldShow());
355 dev_mode_extensions = controller->GetExtensionList(); 358 dev_mode_extensions = controller->GetExtensionList();
356 EXPECT_EQ(2U, dev_mode_extensions.size()); 359 EXPECT_EQ(2U, dev_mode_extensions.size());
357 controller->Show(&bubble); // Simulate showing the bubble. 360 controller->Show(&bubble); // Simulate showing the bubble.
358 EXPECT_EQ(0U, controller->link_click_count()); 361 EXPECT_EQ(0U, controller->link_click_count());
359 EXPECT_EQ(1U, controller->action_click_count()); 362 EXPECT_EQ(1U, controller->action_click_count());
360 EXPECT_EQ(0U, controller->dismiss_click_count()); 363 EXPECT_EQ(0U, controller->dismiss_click_count());
361 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) == NULL); 364 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) == NULL);
362 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) == NULL); 365 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) == NULL);
363 366
364 // Re-enable the extensions (disabled by the action button above). 367 // Re-enable the extensions (disabled by the action button above).
365 service_->EnableExtension(extension_id1_); 368 service_->EnableExtension(extension_id1_);
366 service_->EnableExtension(extension_id2_); 369 service_->EnableExtension(extension_id2_);
367 370
368 // Show the dialog a third time, but now press the learn more link. 371 // Show the dialog a third time, but now press the learn more link.
369 bubble.set_action_on_show( 372 bubble.set_action_on_show(
370 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 373 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
371 controller.reset(new TestDevModeBubbleController( 374 controller.reset(new TestDevModeBubbleController(
372 profile())); 375 profile()));
376 DevModeBubbleController::ClearProfileListForTesting();
373 EXPECT_TRUE(controller->ShouldShow()); 377 EXPECT_TRUE(controller->ShouldShow());
374 dev_mode_extensions = controller->GetExtensionList(); 378 dev_mode_extensions = controller->GetExtensionList();
375 EXPECT_EQ(2U, dev_mode_extensions.size()); 379 EXPECT_EQ(2U, dev_mode_extensions.size());
376 controller->Show(&bubble); // Simulate showing the bubble. 380 controller->Show(&bubble); // Simulate showing the bubble.
377 EXPECT_EQ(1U, controller->link_click_count()); 381 EXPECT_EQ(1U, controller->link_click_count());
378 EXPECT_EQ(0U, controller->action_click_count()); 382 EXPECT_EQ(0U, controller->action_click_count());
379 EXPECT_EQ(0U, controller->dismiss_click_count()); 383 EXPECT_EQ(0U, controller->dismiss_click_count());
380 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL); 384 EXPECT_TRUE(service_->GetExtensionById(extension_id1_, false) != NULL);
381 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL); 385 EXPECT_TRUE(service_->GetExtensionById(extension_id2_, false) != NULL);
382 386
383 // Now disable the unpacked extension. 387 // Now disable the unpacked extension.
384 service_->DisableExtension(extension_id1_, Extension::DISABLE_USER_ACTION); 388 service_->DisableExtension(extension_id1_, Extension::DISABLE_USER_ACTION);
385 service_->DisableExtension(extension_id2_, Extension::DISABLE_USER_ACTION); 389 service_->DisableExtension(extension_id2_, Extension::DISABLE_USER_ACTION);
386 390
387 controller.reset(new TestDevModeBubbleController( 391 controller.reset(new TestDevModeBubbleController(
388 profile())); 392 profile()));
393 DevModeBubbleController::ClearProfileListForTesting();
389 EXPECT_FALSE(controller->ShouldShow()); 394 EXPECT_FALSE(controller->ShouldShow());
390 dev_mode_extensions = controller->GetExtensionList(); 395 dev_mode_extensions = controller->GetExtensionList();
391 EXPECT_EQ(0U, dev_mode_extensions.size()); 396 EXPECT_EQ(0U, dev_mode_extensions.size());
392 } 397 }
393 398
394 } // namespace extensions 399 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698