| OLD | NEW |
| 1 // Copyright (c) 2006-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 // Single threaded tests of UrlInfo functionality. | 5 // Single threaded tests of UrlInfo functionality. |
| 6 | 6 |
| 7 #include <time.h> | 7 #include <time.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/platform_thread.h" | 10 #include "base/platform_thread.h" |
| 11 #include "chrome/browser/net/url_info.h" | 11 #include "chrome/browser/net/url_info.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); | 99 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); |
| 100 info.SetAssignedState(); | 100 info.SetAssignedState(); |
| 101 EXPECT_TRUE(info.is_assigned()); | 101 EXPECT_TRUE(info.is_assigned()); |
| 102 | 102 |
| 103 info.RemoveFromQueue(); // Do the reset. | 103 info.RemoveFromQueue(); // Do the reset. |
| 104 EXPECT_FALSE(info.is_assigned()); | 104 EXPECT_FALSE(info.is_assigned()); |
| 105 | 105 |
| 106 // Since this was a new info instance, and it never got resolved, we land back | 106 // Since this was a new info instance, and it never got resolved, we land back |
| 107 // in a PENDING state rather than FOUND or NO_SUCH_NAME. | 107 // in a PENDING state rather than FOUND or NO_SUCH_NAME. |
| 108 EXPECT_FALSE(info.was_found()); | 108 EXPECT_FALSE(info.was_found()); |
| 109 EXPECT_FALSE(info.was_nonexistant()); | 109 EXPECT_FALSE(info.was_nonexistent()); |
| 110 | 110 |
| 111 // Make sure we're completely re-usable, by going throug a normal flow. | 111 // Make sure we're completely re-usable, by going throug a normal flow. |
| 112 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); | 112 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); |
| 113 info.SetAssignedState(); | 113 info.SetAssignedState(); |
| 114 info.SetFoundState(); | 114 info.SetFoundState(); |
| 115 EXPECT_TRUE(info.was_found()); | 115 EXPECT_TRUE(info.was_found()); |
| 116 | 116 |
| 117 // Use the congestion flow, and check that we end up in the found state. | 117 // Use the congestion flow, and check that we end up in the found state. |
| 118 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); | 118 info.SetQueuedState(UrlInfo::UNIT_TEST_MOTIVATED); |
| 119 info.SetAssignedState(); | 119 info.SetAssignedState(); |
| 120 info.RemoveFromQueue(); // Do the reset. | 120 info.RemoveFromQueue(); // Do the reset. |
| 121 EXPECT_FALSE(info.is_assigned()); | 121 EXPECT_FALSE(info.is_assigned()); |
| 122 EXPECT_TRUE(info.was_found()); // Back to what it was before being queued. | 122 EXPECT_TRUE(info.was_found()); // Back to what it was before being queued. |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 // TODO(jar): Add death test for illegal state changes, and also for setting | 126 // TODO(jar): Add death test for illegal state changes, and also for setting |
| 127 // hostname when already set. | 127 // hostname when already set. |
| 128 | 128 |
| 129 } // namespace | 129 } // namespace |
| OLD | NEW |