| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <ctype.h> | 5 #include <ctype.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "net/base/prioritized_dispatcher.h" | 12 #include "net/base/prioritized_dispatcher.h" |
| 13 #include "net/base/request_priority.h" | 13 #include "net/base/request_priority.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // We rely on the priority enum values being sequential having starting at 0, | 20 // We rely on the priority enum values being sequential having starting at 0, |
| 21 // and increasing for higher priorities. | 21 // and increasing for higher priorities. |
| 22 COMPILE_ASSERT(MINIMUM_PRIORITY == 0u && | 22 static_assert(MINIMUM_PRIORITY == 0u && MINIMUM_PRIORITY == IDLE && |
| 23 MINIMUM_PRIORITY == IDLE && | 23 IDLE < LOWEST && LOWEST < HIGHEST && |
| 24 IDLE < LOWEST && | 24 HIGHEST <= MAXIMUM_PRIORITY, |
| 25 LOWEST < HIGHEST && | 25 "priority indexes incompatible"); |
| 26 HIGHEST <= MAXIMUM_PRIORITY, | |
| 27 priority_indexes_incompatible); | |
| 28 | 26 |
| 29 class PrioritizedDispatcherTest : public testing::Test { | 27 class PrioritizedDispatcherTest : public testing::Test { |
| 30 public: | 28 public: |
| 31 typedef PrioritizedDispatcher::Priority Priority; | 29 typedef PrioritizedDispatcher::Priority Priority; |
| 32 // A job that appends |tag| to |log| when started and '.' when finished. | 30 // A job that appends |tag| to |log| when started and '.' when finished. |
| 33 // This is intended to confirm the execution order of a sequence of jobs added | 31 // This is intended to confirm the execution order of a sequence of jobs added |
| 34 // to the dispatcher. Note that finishing order of jobs does not matter. | 32 // to the dispatcher. Note that finishing order of jobs does not matter. |
| 35 class TestJob : public PrioritizedDispatcher::Job { | 33 class TestJob : public PrioritizedDispatcher::Job { |
| 36 public: | 34 public: |
| 37 TestJob(PrioritizedDispatcher* dispatcher, | 35 TestJob(PrioritizedDispatcher* dispatcher, |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 Prepare(limits); | 558 Prepare(limits); |
| 561 AddJob('a', IDLE); | 559 AddJob('a', IDLE); |
| 562 AddJob('b', IDLE); | 560 AddJob('b', IDLE); |
| 563 EXPECT_DEBUG_DEATH(dispatcher_->Cancel(handle), ""); | 561 EXPECT_DEBUG_DEATH(dispatcher_->Cancel(handle), ""); |
| 564 } | 562 } |
| 565 #endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG) | 563 #endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG) |
| 566 | 564 |
| 567 } // namespace | 565 } // namespace |
| 568 | 566 |
| 569 } // namespace net | 567 } // namespace net |
| OLD | NEW |