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

Side by Side Diff: chrome/browser/notifications/desktop_notifications_unittest.cc

Issue 6542013: Get rid of browser_prefs::RegisterAllPrefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix metrics_log_unittest.cc Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/notifications/desktop_notifications_unittest.h" 5 #include "chrome/browser/notifications/desktop_notifications_unittest.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
11 #include "chrome/common/render_messages_params.h" 12 #include "chrome/common/render_messages_params.h"
12 #include "chrome/test/testing_pref_service.h" 13 #include "chrome/test/testing_pref_service.h"
13 14
14 // static 15 // static
15 const int MockBalloonCollection::kMockBalloonSpace = 5; 16 const int MockBalloonCollection::kMockBalloonSpace = 5;
16 17
17 // static 18 // static
18 std::string DesktopNotificationsTest::log_output_; 19 std::string DesktopNotificationsTest::log_output_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 76 }
76 77
77 DesktopNotificationsTest::DesktopNotificationsTest() 78 DesktopNotificationsTest::DesktopNotificationsTest()
78 : ui_thread_(BrowserThread::UI, &message_loop_) { 79 : ui_thread_(BrowserThread::UI, &message_loop_) {
79 } 80 }
80 81
81 DesktopNotificationsTest::~DesktopNotificationsTest() { 82 DesktopNotificationsTest::~DesktopNotificationsTest() {
82 } 83 }
83 84
84 void DesktopNotificationsTest::SetUp() { 85 void DesktopNotificationsTest::SetUp() {
86 browser::RegisterLocalState(&local_state_);
85 profile_.reset(new TestingProfile()); 87 profile_.reset(new TestingProfile());
86 balloon_collection_ = new MockBalloonCollection(); 88 balloon_collection_ = new MockBalloonCollection();
87 ui_manager_.reset( 89 ui_manager_.reset(new NotificationUIManager(&local_state_));
88 new NotificationUIManager(profile_->GetTestingPrefService()));
89 ui_manager_->Initialize(balloon_collection_); 90 ui_manager_->Initialize(balloon_collection_);
90 balloon_collection_->set_space_change_listener(ui_manager_.get()); 91 balloon_collection_->set_space_change_listener(ui_manager_.get());
91 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); 92 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get()));
92 log_output_.clear(); 93 log_output_.clear();
93 } 94 }
94 95
95 void DesktopNotificationsTest::TearDown() { 96 void DesktopNotificationsTest::TearDown() {
96 service_.reset(NULL); 97 service_.reset(NULL);
97 ui_manager_.reset(NULL); 98 ui_manager_.reset(NULL);
98 profile_.reset(NULL); 99 profile_.reset(NULL);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 EXPECT_TRUE(box.Contains(gfx::Point(min_x, min_y))); 366 EXPECT_TRUE(box.Contains(gfx::Point(min_x, min_y)));
366 EXPECT_TRUE(box.Contains(gfx::Point(min_x, max_y))); 367 EXPECT_TRUE(box.Contains(gfx::Point(min_x, max_y)));
367 EXPECT_TRUE(box.Contains(gfx::Point(max_x, min_y))); 368 EXPECT_TRUE(box.Contains(gfx::Point(max_x, min_y)));
368 EXPECT_TRUE(box.Contains(gfx::Point(max_x, max_y))); 369 EXPECT_TRUE(box.Contains(gfx::Point(max_x, max_y)));
369 } 370 }
370 } 371 }
371 } 372 }
372 373
373 TEST_F(DesktopNotificationsTest, TestPositionPreference) { 374 TEST_F(DesktopNotificationsTest, TestPositionPreference) {
374 // Set position preference to lower right. 375 // Set position preference to lower right.
375 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 376 local_state_.SetInteger(prefs::kDesktopNotificationPosition,
376 BalloonCollection::LOWER_RIGHT); 377 BalloonCollection::LOWER_RIGHT);
377 378
378 // Create some notifications. 379 // Create some notifications.
379 ViewHostMsg_ShowNotification_Params params = StandardTestNotification(); 380 ViewHostMsg_ShowNotification_Params params = StandardTestNotification();
380 for (int id = 0; id <= 3; ++id) { 381 for (int id = 0; id <= 3; ++id) {
381 params.notification_id = id; 382 params.notification_id = id;
382 EXPECT_TRUE(service_->ShowDesktopNotification( 383 EXPECT_TRUE(service_->ShowDesktopNotification(
383 params, 0, 0, DesktopNotificationService::PageNotification)); 384 params, 0, 0, DesktopNotificationService::PageNotification));
384 } 385 }
385 386
386 std::deque<Balloon*>& balloons = balloon_collection_->balloons(); 387 std::deque<Balloon*>& balloons = balloon_collection_->balloons();
(...skipping 17 matching lines...) Expand all
404 EXPECT_LT(current_y, last_y); 405 EXPECT_LT(current_y, last_y);
405 #endif 406 #endif
406 } 407 }
407 408
408 last_x = current_x; 409 last_x = current_x;
409 last_y = current_y; 410 last_y = current_y;
410 } 411 }
411 412
412 // Now change the position to upper right. This should cause an immediate 413 // Now change the position to upper right. This should cause an immediate
413 // repositioning, and we check for the reverse ordering. 414 // repositioning, and we check for the reverse ordering.
414 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 415 local_state_.SetInteger(prefs::kDesktopNotificationPosition,
415 BalloonCollection::UPPER_RIGHT); 416 BalloonCollection::UPPER_RIGHT);
416 last_x = -1; 417 last_x = -1;
417 last_y = -1; 418 last_y = -1;
418 419
419 for (iter = balloons.begin(); iter != balloons.end(); ++iter) { 420 for (iter = balloons.begin(); iter != balloons.end(); ++iter) {
420 int current_x = (*iter)->GetPosition().x(); 421 int current_x = (*iter)->GetPosition().x();
421 int current_y = (*iter)->GetPosition().y(); 422 int current_y = (*iter)->GetPosition().y();
422 423
423 if (last_x > 0) 424 if (last_x > 0)
424 EXPECT_EQ(last_x, current_x); 425 EXPECT_EQ(last_x, current_x);
425 426
426 if (last_y > 0) { 427 if (last_y > 0) {
427 #if defined(OS_MACOSX) 428 #if defined(OS_MACOSX)
428 EXPECT_LT(current_y, last_y); 429 EXPECT_LT(current_y, last_y);
429 #else 430 #else
430 EXPECT_GT(current_y, last_y); 431 EXPECT_GT(current_y, last_y);
431 #endif 432 #endif
432 } 433 }
433 434
434 last_x = current_x; 435 last_x = current_x;
435 last_y = current_y; 436 last_y = current_y;
436 } 437 }
437 438
438 // Now change the position to upper left. Confirm that the X value for the 439 // Now change the position to upper left. Confirm that the X value for the
439 // balloons gets smaller. 440 // balloons gets smaller.
440 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 441 local_state_.SetInteger(prefs::kDesktopNotificationPosition,
441 BalloonCollection::UPPER_LEFT); 442 BalloonCollection::UPPER_LEFT);
442 443
443 int current_x = (*balloons.begin())->GetPosition().x(); 444 int current_x = (*balloons.begin())->GetPosition().x();
444 EXPECT_LT(current_x, last_x); 445 EXPECT_LT(current_x, last_x);
445 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698