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 "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 5 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 } // extensions | 21 } // extensions |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 using api::activity_log_private::ExtensionActivity; | 25 using api::activity_log_private::ExtensionActivity; |
26 | 26 |
27 typedef testing::Test ActivityLogApiUnitTest; | 27 typedef testing::Test ActivityLogApiUnitTest; |
28 | 28 |
29 TEST_F(ActivityLogApiUnitTest, ConvertChromeApiAction) { | 29 TEST_F(ActivityLogApiUnitTest, ConvertChromeApiAction) { |
30 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 30 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
31 args->Set(0, new base::StringValue("hello")); | 31 args->Set(0, new base::Value("hello")); |
32 args->Set(1, new base::StringValue("world")); | 32 args->Set(1, new base::Value("world")); |
33 scoped_refptr<Action> action(new Action(kExtensionId, | 33 scoped_refptr<Action> action(new Action(kExtensionId, |
34 base::Time::Now(), | 34 base::Time::Now(), |
35 Action::ACTION_API_CALL, | 35 Action::ACTION_API_CALL, |
36 kApiCall)); | 36 kApiCall)); |
37 action->set_args(std::move(args)); | 37 action->set_args(std::move(args)); |
38 ExtensionActivity result = action->ConvertToExtensionActivity(); | 38 ExtensionActivity result = action->ConvertToExtensionActivity(); |
39 ASSERT_EQ(api::activity_log_private::EXTENSION_ACTIVITY_TYPE_API_CALL, | 39 ASSERT_EQ(api::activity_log_private::EXTENSION_ACTIVITY_TYPE_API_CALL, |
40 result.activity_type); | 40 result.activity_type); |
41 ASSERT_EQ(kExtensionId, *(result.extension_id.get())); | 41 ASSERT_EQ(kExtensionId, *(result.extension_id.get())); |
42 ASSERT_EQ(kApiCall, *(result.api_call.get())); | 42 ASSERT_EQ(kApiCall, *(result.api_call.get())); |
43 ASSERT_EQ(kArgs, *(result.args.get())); | 43 ASSERT_EQ(kArgs, *(result.args.get())); |
44 ASSERT_EQ(NULL, result.activity_id.get()); | 44 ASSERT_EQ(NULL, result.activity_id.get()); |
45 } | 45 } |
46 | 46 |
47 TEST_F(ActivityLogApiUnitTest, ConvertDomAction) { | 47 TEST_F(ActivityLogApiUnitTest, ConvertDomAction) { |
48 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 48 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
49 args->Set(0, new base::StringValue("hello")); | 49 args->Set(0, new base::Value("hello")); |
50 args->Set(1, new base::StringValue("world")); | 50 args->Set(1, new base::Value("world")); |
51 scoped_refptr<Action> action(new Action(kExtensionId, | 51 scoped_refptr<Action> action(new Action(kExtensionId, |
52 base::Time::Now(), | 52 base::Time::Now(), |
53 Action::ACTION_DOM_ACCESS, | 53 Action::ACTION_DOM_ACCESS, |
54 kApiCall, | 54 kApiCall, |
55 12345)); | 55 12345)); |
56 action->set_args(std::move(args)); | 56 action->set_args(std::move(args)); |
57 action->set_page_url(GURL("http://www.google.com")); | 57 action->set_page_url(GURL("http://www.google.com")); |
58 action->set_page_title("Title"); | 58 action->set_page_title("Title"); |
59 action->mutable_other()->SetInteger(activity_log_constants::kActionDomVerb, | 59 action->mutable_other()->SetInteger(activity_log_constants::kActionDomVerb, |
60 DomActionType::INSERTED); | 60 DomActionType::INSERTED); |
61 action->mutable_other()->SetBoolean(activity_log_constants::kActionPrerender, | 61 action->mutable_other()->SetBoolean(activity_log_constants::kActionPrerender, |
62 false); | 62 false); |
63 ExtensionActivity result = action->ConvertToExtensionActivity(); | 63 ExtensionActivity result = action->ConvertToExtensionActivity(); |
64 ASSERT_EQ(kExtensionId, *(result.extension_id.get())); | 64 ASSERT_EQ(kExtensionId, *(result.extension_id.get())); |
65 ASSERT_EQ("http://www.google.com/", *(result.page_url.get())); | 65 ASSERT_EQ("http://www.google.com/", *(result.page_url.get())); |
66 ASSERT_EQ("Title", *(result.page_title.get())); | 66 ASSERT_EQ("Title", *(result.page_title.get())); |
67 ASSERT_EQ(kApiCall, *(result.api_call.get())); | 67 ASSERT_EQ(kApiCall, *(result.api_call.get())); |
68 ASSERT_EQ(kArgs, *(result.args.get())); | 68 ASSERT_EQ(kArgs, *(result.args.get())); |
69 std::unique_ptr<ExtensionActivity::Other> other(std::move(result.other)); | 69 std::unique_ptr<ExtensionActivity::Other> other(std::move(result.other)); |
70 ASSERT_EQ(api::activity_log_private::EXTENSION_ACTIVITY_DOM_VERB_INSERTED, | 70 ASSERT_EQ(api::activity_log_private::EXTENSION_ACTIVITY_DOM_VERB_INSERTED, |
71 other->dom_verb); | 71 other->dom_verb); |
72 ASSERT_TRUE(other->prerender.get()); | 72 ASSERT_TRUE(other->prerender.get()); |
73 ASSERT_EQ("12345", *(result.activity_id.get())); | 73 ASSERT_EQ("12345", *(result.activity_id.get())); |
74 } | 74 } |
75 | 75 |
76 } // namespace extensions | 76 } // namespace extensions |
OLD | NEW |