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

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

Issue 6292017: Extended: Add "system" URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments 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) 2010 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/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 : ui_thread_(BrowserThread::UI, &message_loop_) { 70 : ui_thread_(BrowserThread::UI, &message_loop_) {
71 } 71 }
72 72
73 DesktopNotificationsTest::~DesktopNotificationsTest() { 73 DesktopNotificationsTest::~DesktopNotificationsTest() {
74 } 74 }
75 75
76 void DesktopNotificationsTest::SetUp() { 76 void DesktopNotificationsTest::SetUp() {
77 profile_.reset(new TestingProfile()); 77 profile_.reset(new TestingProfile());
78 balloon_collection_ = new MockBalloonCollection(); 78 balloon_collection_ = new MockBalloonCollection();
79 ui_manager_.reset( 79 ui_manager_.reset(
80 new NotificationUIManager(profile_->GetTestingPrefService())); 80 new NotificationUIManager(profile_->GetLocalState()));
81 ui_manager_->Initialize(balloon_collection_); 81 ui_manager_->Initialize(balloon_collection_);
82 balloon_collection_->set_space_change_listener(ui_manager_.get()); 82 balloon_collection_->set_space_change_listener(ui_manager_.get());
83 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); 83 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get()));
84 log_output_.clear(); 84 log_output_.clear();
85 } 85 }
86 86
87 void DesktopNotificationsTest::TearDown() { 87 void DesktopNotificationsTest::TearDown() {
88 service_.reset(NULL); 88 service_.reset(NULL);
89 ui_manager_.reset(NULL); 89 ui_manager_.reset(NULL);
90 profile_.reset(NULL); 90 profile_.reset(NULL);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_TRUE(box.Contains(gfx::Point(min_x, min_y))); 357 EXPECT_TRUE(box.Contains(gfx::Point(min_x, min_y)));
358 EXPECT_TRUE(box.Contains(gfx::Point(min_x, max_y))); 358 EXPECT_TRUE(box.Contains(gfx::Point(min_x, max_y)));
359 EXPECT_TRUE(box.Contains(gfx::Point(max_x, min_y))); 359 EXPECT_TRUE(box.Contains(gfx::Point(max_x, min_y)));
360 EXPECT_TRUE(box.Contains(gfx::Point(max_x, max_y))); 360 EXPECT_TRUE(box.Contains(gfx::Point(max_x, max_y)));
361 } 361 }
362 } 362 }
363 } 363 }
364 364
365 TEST_F(DesktopNotificationsTest, TestPositionPreference) { 365 TEST_F(DesktopNotificationsTest, TestPositionPreference) {
366 // Set position preference to lower right. 366 // Set position preference to lower right.
367 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 367 profile_->GetLocalState()->SetInteger(prefs::kDesktopNotificationPosition,
368 BalloonCollection::LOWER_RIGHT); 368 BalloonCollection::LOWER_RIGHT);
369 369
370 // Create some notifications. 370 // Create some notifications.
371 ViewHostMsg_ShowNotification_Params params = StandardTestNotification(); 371 ViewHostMsg_ShowNotification_Params params = StandardTestNotification();
372 for (int id = 0; id <= 3; ++id) { 372 for (int id = 0; id <= 3; ++id) {
373 params.notification_id = id; 373 params.notification_id = id;
374 EXPECT_TRUE(service_->ShowDesktopNotification( 374 EXPECT_TRUE(service_->ShowDesktopNotification(
375 params, 0, 0, DesktopNotificationService::PageNotification)); 375 params, 0, 0, DesktopNotificationService::PageNotification));
376 } 376 }
377 377
378 std::deque<Balloon*>& balloons = balloon_collection_->balloons(); 378 std::deque<Balloon*>& balloons = balloon_collection_->balloons();
(...skipping 17 matching lines...) Expand all
396 EXPECT_LT(current_y, last_y); 396 EXPECT_LT(current_y, last_y);
397 #endif 397 #endif
398 } 398 }
399 399
400 last_x = current_x; 400 last_x = current_x;
401 last_y = current_y; 401 last_y = current_y;
402 } 402 }
403 403
404 // Now change the position to upper right. This should cause an immediate 404 // Now change the position to upper right. This should cause an immediate
405 // repositioning, and we check for the reverse ordering. 405 // repositioning, and we check for the reverse ordering.
406 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 406 profile_->GetLocalState()->SetInteger(prefs::kDesktopNotificationPosition,
407 BalloonCollection::UPPER_RIGHT); 407 BalloonCollection::UPPER_RIGHT);
408 last_x = -1; 408 last_x = -1;
409 last_y = -1; 409 last_y = -1;
410 410
411 for (iter = balloons.begin(); iter != balloons.end(); ++iter) { 411 for (iter = balloons.begin(); iter != balloons.end(); ++iter) {
412 int current_x = (*iter)->GetPosition().x(); 412 int current_x = (*iter)->GetPosition().x();
413 int current_y = (*iter)->GetPosition().y(); 413 int current_y = (*iter)->GetPosition().y();
414 414
415 if (last_x > 0) 415 if (last_x > 0)
416 EXPECT_EQ(last_x, current_x); 416 EXPECT_EQ(last_x, current_x);
417 417
418 if (last_y > 0) { 418 if (last_y > 0) {
419 #if defined(OS_MACOSX) 419 #if defined(OS_MACOSX)
420 EXPECT_LT(current_y, last_y); 420 EXPECT_LT(current_y, last_y);
421 #else 421 #else
422 EXPECT_GT(current_y, last_y); 422 EXPECT_GT(current_y, last_y);
423 #endif 423 #endif
424 } 424 }
425 425
426 last_x = current_x; 426 last_x = current_x;
427 last_y = current_y; 427 last_y = current_y;
428 } 428 }
429 429
430 // Now change the position to upper left. Confirm that the X value for the 430 // Now change the position to upper left. Confirm that the X value for the
431 // balloons gets smaller. 431 // balloons gets smaller.
432 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, 432 profile_->GetLocalState()->SetInteger(prefs::kDesktopNotificationPosition,
433 BalloonCollection::UPPER_LEFT); 433 BalloonCollection::UPPER_LEFT);
434 434
435 int current_x = (*balloons.begin())->GetPosition().x(); 435 int current_x = (*balloons.begin())->GetPosition().x();
436 EXPECT_LT(current_x, last_x); 436 EXPECT_LT(current_x, last_x);
437 } 437 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698