OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <time.h> | 5 #include <time.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 icon_subresource_hostname, | 534 icon_subresource_hostname, |
535 recovered_referral_list)); | 535 recovered_referral_list)); |
536 EXPECT_EQ(kLatencyNotFound, | 536 EXPECT_EQ(kLatencyNotFound, |
537 GetLatencyFromSerialization(motivation_hostname, | 537 GetLatencyFromSerialization(motivation_hostname, |
538 img_subresource_hostname, | 538 img_subresource_hostname, |
539 recovered_referral_list)); | 539 recovered_referral_list)); |
540 | 540 |
541 master.Shutdown(); | 541 master.Shutdown(); |
542 } | 542 } |
543 | 543 |
544 | |
545 TEST_F(DnsMasterTest, PriorityQueuePushPopTest) { | |
546 DnsMaster::HostNameQueue queue; | |
547 | |
548 // First check high priority queue FIFO functionality. | |
549 EXPECT_TRUE(queue.IsEmpty()); | |
550 queue.Push("a", DnsHostInfo::LEARNED_REFERAL_MOTIVATED); | |
551 EXPECT_FALSE(queue.IsEmpty()); | |
552 queue.Push("b", DnsHostInfo::MOUSE_OVER_MOTIVATED); | |
553 EXPECT_FALSE(queue.IsEmpty()); | |
554 EXPECT_EQ(queue.Pop(), "a"); | |
555 EXPECT_FALSE(queue.IsEmpty()); | |
556 EXPECT_EQ(queue.Pop(), "b"); | |
557 EXPECT_TRUE(queue.IsEmpty()); | |
558 | |
559 // Then check low priority queue FIFO functionality. | |
560 queue.IsEmpty(); | |
561 queue.Push("a", DnsHostInfo::PAGE_SCAN_MOTIVATED); | |
562 EXPECT_FALSE(queue.IsEmpty()); | |
563 queue.Push("b", DnsHostInfo::OMNIBOX_MOTIVATED); | |
564 EXPECT_FALSE(queue.IsEmpty()); | |
565 EXPECT_EQ(queue.Pop(), "a"); | |
566 EXPECT_FALSE(queue.IsEmpty()); | |
567 EXPECT_EQ(queue.Pop(), "b"); | |
568 EXPECT_TRUE(queue.IsEmpty()); | |
569 } | |
570 | |
571 TEST_F(DnsMasterTest, PriorityQueueReorderTest) { | |
572 DnsMaster::HostNameQueue queue; | |
573 | |
574 // Push all the low priority items. | |
575 EXPECT_TRUE(queue.IsEmpty()); | |
576 queue.Push("scan", DnsHostInfo::PAGE_SCAN_MOTIVATED); | |
577 queue.Push("unit", DnsHostInfo::UNIT_TEST_MOTIVATED); | |
578 queue.Push("lmax", DnsHostInfo::LINKED_MAX_MOTIVATED); | |
579 queue.Push("omni", DnsHostInfo::OMNIBOX_MOTIVATED); | |
580 queue.Push("startup", DnsHostInfo::STARTUP_LIST_MOTIVATED); | |
581 queue.Push("omni", DnsHostInfo::OMNIBOX_MOTIVATED); | |
582 | |
583 // Push all the high prority items | |
584 queue.Push("learned", DnsHostInfo::LEARNED_REFERAL_MOTIVATED); | |
585 queue.Push("refer", DnsHostInfo::STATIC_REFERAL_MOTIVATED); | |
586 queue.Push("mouse", DnsHostInfo::MOUSE_OVER_MOTIVATED); | |
587 | |
588 // Check that high priority stuff comes out first, and in FIFO order. | |
589 EXPECT_EQ(queue.Pop(), "learned"); | |
590 EXPECT_EQ(queue.Pop(), "refer"); | |
591 EXPECT_EQ(queue.Pop(), "mouse"); | |
592 | |
593 // ...and then low priority strings. | |
594 EXPECT_EQ(queue.Pop(), "scan"); | |
595 EXPECT_EQ(queue.Pop(), "unit"); | |
596 EXPECT_EQ(queue.Pop(), "lmax"); | |
597 EXPECT_EQ(queue.Pop(), "omni"); | |
598 EXPECT_EQ(queue.Pop(), "startup"); | |
599 EXPECT_EQ(queue.Pop(), "omni"); | |
600 | |
601 EXPECT_TRUE(queue.IsEmpty()); | |
602 } | |
603 | |
604 | |
605 | |
606 | |
607 } // namespace chrome_browser_net | 544 } // namespace chrome_browser_net |
OLD | NEW |