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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
6 // | 6 // |
7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // in order. | 44 // in order. |
45 const InterruptReasonAssociation current_reasons[] = { | 45 const InterruptReasonAssociation current_reasons[] = { |
46 #define INTERRUPT_REASON(a, b) { #a, b }, | 46 #define INTERRUPT_REASON(a, b) { #a, b }, |
47 #include "content/public/browser/download_interrupt_reason_values.h" | 47 #include "content/public/browser/download_interrupt_reason_values.h" |
48 #undef INTERRUPT_REASON | 48 #undef INTERRUPT_REASON |
49 }; | 49 }; |
50 | 50 |
51 // This represents a list of all reasons we've previously used; | 51 // This represents a list of all reasons we've previously used; |
52 // Do Not Remove Any Entries From This List. | 52 // Do Not Remove Any Entries From This List. |
53 const InterruptReasonAssociation historical_reasons[] = { | 53 const InterruptReasonAssociation historical_reasons[] = { |
54 {"FILE_FAILED", 1}, | 54 {"FILE_FAILED", 1}, |
55 {"FILE_ACCESS_DENIED", 2}, | 55 {"FILE_ACCESS_DENIED", 2}, |
56 {"FILE_NO_SPACE", 3}, | 56 {"FILE_NO_SPACE", 3}, |
57 {"FILE_NAME_TOO_LONG", 5}, | 57 {"FILE_NAME_TOO_LONG", 5}, |
58 {"FILE_TOO_LARGE", 6}, | 58 {"FILE_TOO_LARGE", 6}, |
59 {"FILE_VIRUS_INFECTED", 7}, | 59 {"FILE_VIRUS_INFECTED", 7}, |
60 {"FILE_TRANSIENT_ERROR", 10}, | 60 {"FILE_TRANSIENT_ERROR", 10}, |
61 {"FILE_BLOCKED", 11}, | 61 {"FILE_BLOCKED", 11}, |
62 {"FILE_SECURITY_CHECK_FAILED", 12}, | 62 {"FILE_SECURITY_CHECK_FAILED", 12}, |
63 {"FILE_TOO_SHORT", 13}, | 63 {"FILE_TOO_SHORT", 13}, |
64 {"NETWORK_FAILED", 20}, | 64 {"NETWORK_FAILED", 20}, |
65 {"NETWORK_TIMEOUT", 21}, | 65 {"NETWORK_TIMEOUT", 21}, |
66 {"NETWORK_DISCONNECTED", 22}, | 66 {"NETWORK_DISCONNECTED", 22}, |
67 {"NETWORK_SERVER_DOWN", 23}, | 67 {"NETWORK_SERVER_DOWN", 23}, |
68 {"NETWORK_INVALID_REQUEST", 24}, | 68 {"NETWORK_INVALID_REQUEST", 24}, |
69 {"SERVER_FAILED", 30}, | 69 {"SERVER_FAILED", 30}, |
70 {"SERVER_NO_RANGE", 31}, | 70 {"SERVER_NO_RANGE", 31}, |
71 {"SERVER_PRECONDITION", 32}, | 71 {"SERVER_PRECONDITION", 32}, |
72 {"SERVER_BAD_CONTENT", 33}, | 72 {"SERVER_BAD_CONTENT", 33}, |
73 {"SERVER_UNAUTHORIZED", 34}, | 73 {"SERVER_UNAUTHORIZED", 34}, |
74 {"SERVER_CERT_PROBLEM", 35}, | 74 {"SERVER_CERT_PROBLEM", 35}, |
75 {"SERVER_FORBIDDEN", 36}, | 75 {"SERVER_FORBIDDEN", 36}, |
76 {"USER_CANCELED", 40}, | 76 {"SERVER_UNREACHABLE", 37}, |
77 {"USER_SHUTDOWN", 41}, | 77 {"USER_CANCELED", 40}, |
78 {"CRASH", 50}, | 78 {"USER_SHUTDOWN", 41}, |
| 79 {"CRASH", 50}, |
79 }; | 80 }; |
80 | 81 |
81 // Make sure no one has changed a DownloadInterruptReason we've previously | 82 // Make sure no one has changed a DownloadInterruptReason we've previously |
82 // persisted. | 83 // persisted. |
83 TEST_F(ContentHistoryBackendDBTest, | 84 TEST_F(ContentHistoryBackendDBTest, |
84 ConfirmDownloadInterruptReasonBackwardsCompatible) { | 85 ConfirmDownloadInterruptReasonBackwardsCompatible) { |
85 // Are there any cases in which a historical number has been repurposed | 86 // Are there any cases in which a historical number has been repurposed |
86 // for an error other than it's original? | 87 // for an error other than it's original? |
87 for (size_t i = 0; i < arraysize(current_reasons); i++) { | 88 for (size_t i = 0; i < arraysize(current_reasons); i++) { |
88 const InterruptReasonAssociation& cur_reason(current_reasons[i]); | 89 const InterruptReasonAssociation& cur_reason(current_reasons[i]); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 123 } |
123 | 124 |
124 EXPECT_TRUE(found) | 125 EXPECT_TRUE(found) |
125 << "Error \"" << cur_reason.name << "\" not found in historical list." | 126 << "Error \"" << cur_reason.name << "\" not found in historical list." |
126 << std::endl | 127 << std::endl |
127 << "Please add it."; | 128 << "Please add it."; |
128 } | 129 } |
129 } | 130 } |
130 } // namespace | 131 } // namespace |
131 } // namespace history | 132 } // namespace history |
OLD | NEW |