OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/time/time.h" | 5 #include "base/time/time.h" |
6 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" | 6 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |
7 #include "chrome/browser/extensions/activity_log/uma_policy.h" | 7 #include "chrome/browser/extensions/activity_log/uma_policy.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "extensions/common/dom_action_types.h" | 9 #include "extensions/common/dom_action_types.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 (1 << UmaPolicy::CREATED_SCRIPT) & policy->MatchActionToStatus(action)); | 82 (1 << UmaPolicy::CREATED_SCRIPT) & policy->MatchActionToStatus(action)); |
83 ASSERT_TRUE( | 83 ASSERT_TRUE( |
84 (1 << UmaPolicy::DOM_METHOD) & policy->MatchActionToStatus(action)); | 84 (1 << UmaPolicy::DOM_METHOD) & policy->MatchActionToStatus(action)); |
85 | 85 |
86 policy->Close(); | 86 policy->Close(); |
87 } | 87 } |
88 | 88 |
89 TEST_F(UmaPolicyTest, SiteUrlTest) { | 89 TEST_F(UmaPolicyTest, SiteUrlTest) { |
90 UmaPolicy* policy = new UmaPolicy(profile_.get()); | 90 UmaPolicy* policy = new UmaPolicy(profile_.get()); |
91 | 91 |
92 const std::string site0 = "http://www.zzz.com"; | 92 const std::string site0 = "http://www.zzz.com/"; |
93 const std::string site1 = "http://www.foo.com"; | 93 const std::string site1 = "http://www.foo.com/"; |
94 const std::string site2 = "http://www.google.com#a"; | 94 const std::string site2 = "http://www.google.com#a"; |
95 const std::string site3 = "http://www.google.com#bb"; | 95 const std::string site3 = "http://www.google.com#bb"; |
96 | 96 |
97 // Record some opened sites. | 97 // Record some opened sites. |
98 policy->SetupOpenedPage(site1); | 98 policy->SetupOpenedPage(site1); |
99 policy->SetupOpenedPage(site2); | 99 policy->SetupOpenedPage(site2); |
100 policy->SetupOpenedPage(site2); | 100 policy->SetupOpenedPage(site2); |
101 policy->SetupOpenedPage(site3); | 101 policy->SetupOpenedPage(site3); |
102 policy->SetupOpenedPage(site3); | 102 policy->SetupOpenedPage(site3); |
103 policy->SetupOpenedPage(site3); | 103 policy->SetupOpenedPage(site3); |
104 | 104 |
105 // Check that site1, site2, and site3 were recorded. | 105 // Check that site1, site2, and site3 were recorded. |
106 ASSERT_EQ(3u, policy->url_status().size()); | 106 ASSERT_EQ(3u, policy->url_status().size()); |
107 ASSERT_EQ(1, policy->url_status()[site1][UmaPolicy::kNumberOfTabs]); | 107 ASSERT_EQ(1, policy->url_status()[site1][UmaPolicy::kNumberOfTabs]); |
108 ASSERT_EQ(2, policy->url_status()[site2][UmaPolicy::kNumberOfTabs]); | 108 ASSERT_EQ(2, policy->url_status()[site2][UmaPolicy::kNumberOfTabs]); |
109 ASSERT_EQ(3, policy->url_status()[site3][UmaPolicy::kNumberOfTabs]); | 109 ASSERT_EQ(3, policy->url_status()[site3][UmaPolicy::kNumberOfTabs]); |
110 | 110 |
111 // Remove some sites. | 111 // Remove some sites. |
112 policy->CleanupClosedPage(site0); | 112 policy->CleanupClosedPage(site0, NULL); |
113 policy->CleanupClosedPage(site2); | 113 policy->CleanupClosedPage(site2, NULL); |
114 policy->CleanupClosedPage(site2); | 114 policy->CleanupClosedPage(site2, NULL); |
115 policy->CleanupClosedPage(site3); | 115 policy->CleanupClosedPage(site3, NULL); |
116 | 116 |
117 // Check that the removal worked. | 117 // Check that the removal worked. |
118 ASSERT_EQ(2u, policy->url_status().size()); | 118 ASSERT_EQ(2u, policy->url_status().size()); |
119 ASSERT_EQ(1, policy->url_status()[site1][UmaPolicy::kNumberOfTabs]); | 119 ASSERT_EQ(1, policy->url_status()[site1][UmaPolicy::kNumberOfTabs]); |
120 ASSERT_EQ(2, policy->url_status()[site3][UmaPolicy::kNumberOfTabs]); | 120 ASSERT_EQ(2, policy->url_status()[site3][UmaPolicy::kNumberOfTabs]); |
121 | 121 |
122 policy->Close(); | 122 policy->Close(); |
123 } | 123 } |
124 | 124 |
125 TEST_F(UmaPolicyTest, ProcessActionTest) { | 125 TEST_F(UmaPolicyTest, ProcessActionTest) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 UmaPolicy::CleanURL(GURL("http://www.cnn.com"))); | 216 UmaPolicy::CleanURL(GURL("http://www.cnn.com"))); |
217 ASSERT_EQ("http://www.cnn.com/", | 217 ASSERT_EQ("http://www.cnn.com/", |
218 UmaPolicy::CleanURL(GURL("http://www.cnn.com/#a"))); | 218 UmaPolicy::CleanURL(GURL("http://www.cnn.com/#a"))); |
219 ASSERT_EQ("http://www.cnn.com/", | 219 ASSERT_EQ("http://www.cnn.com/", |
220 UmaPolicy::CleanURL(GURL("http://www.cnn.com/#aaaa"))); | 220 UmaPolicy::CleanURL(GURL("http://www.cnn.com/#aaaa"))); |
221 ASSERT_EQ("http://www.cnn.com/?q=a", | 221 ASSERT_EQ("http://www.cnn.com/?q=a", |
222 UmaPolicy::CleanURL(GURL("http://www.cnn.com/?q=a"))); | 222 UmaPolicy::CleanURL(GURL("http://www.cnn.com/?q=a"))); |
223 } | 223 } |
224 | 224 |
225 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |