Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_interactive_test.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
(...skipping 27 matching lines...) Expand all
38 // Note that "last focused" means the "top" most window. 38 // Note that "last focused" means the "top" most window.
39 Browser* new_browser = CreateBrowser(browser()->profile()); 39 Browser* new_browser = CreateBrowser(browser()->profile());
40 int focused_window_id = 40 int focused_window_id =
41 extensions::ExtensionTabUtil::GetWindowId(new_browser); 41 extensions::ExtensionTabUtil::GetWindowId(new_browser);
42 42
43 scoped_refptr<extensions::WindowsGetLastFocusedFunction> function = 43 scoped_refptr<extensions::WindowsGetLastFocusedFunction> function =
44 new extensions::WindowsGetLastFocusedFunction(); 44 new extensions::WindowsGetLastFocusedFunction();
45 scoped_refptr<extensions::Extension> extension( 45 scoped_refptr<extensions::Extension> extension(
46 extensions::test_util::CreateEmptyExtension()); 46 extensions::test_util::CreateEmptyExtension());
47 function->set_extension(extension.get()); 47 function->set_extension(extension.get());
48 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( 48 std::unique_ptr<base::DictionaryValue> result(
49 utils::RunFunctionAndReturnSingleResult(function.get(), 49 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult(
50 "[]", 50 function.get(), "[]", new_browser)));
51 new_browser)));
52 51
53 // The id should always match the last focused window and does not depend 52 // The id should always match the last focused window and does not depend
54 // on what was passed to RunFunctionAndReturnSingleResult. 53 // on what was passed to RunFunctionAndReturnSingleResult.
55 EXPECT_EQ(focused_window_id, api_test_utils::GetInteger(result.get(), "id")); 54 EXPECT_EQ(focused_window_id, api_test_utils::GetInteger(result.get(), "id"));
56 base::ListValue* tabs = NULL; 55 base::ListValue* tabs = NULL;
57 EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); 56 EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs));
58 57
59 function = new extensions::WindowsGetLastFocusedFunction(); 58 function = new extensions::WindowsGetLastFocusedFunction();
60 function->set_extension(extension.get()); 59 function->set_extension(extension.get());
61 result.reset(utils::ToDictionary( 60 result.reset(utils::ToDictionary(
(...skipping 27 matching lines...) Expand all
89 88
90 GURL url; 89 GURL url;
91 AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK, 90 AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK,
92 true); 91 true);
93 int focused_window_id = 92 int focused_window_id =
94 extensions::ExtensionTabUtil::GetWindowId(focused_window); 93 extensions::ExtensionTabUtil::GetWindowId(focused_window);
95 94
96 // Get tabs in the 'last focused' window called from non-focused browser. 95 // Get tabs in the 'last focused' window called from non-focused browser.
97 scoped_refptr<extensions::TabsQueryFunction> function = 96 scoped_refptr<extensions::TabsQueryFunction> function =
98 new extensions::TabsQueryFunction(); 97 new extensions::TabsQueryFunction();
99 scoped_ptr<base::ListValue> result(utils::ToList( 98 std::unique_ptr<base::ListValue> result(
100 utils::RunFunctionAndReturnSingleResult(function.get(), 99 utils::ToList(utils::RunFunctionAndReturnSingleResult(
101 "[{\"lastFocusedWindow\":true}]", 100 function.get(), "[{\"lastFocusedWindow\":true}]", browser())));
102 browser())));
103 101
104 base::ListValue* result_tabs = result.get(); 102 base::ListValue* result_tabs = result.get();
105 // We should have one initial tab and one added tab. 103 // We should have one initial tab and one added tab.
106 EXPECT_EQ(2u, result_tabs->GetSize()); 104 EXPECT_EQ(2u, result_tabs->GetSize());
107 for (size_t i = 0; i < result_tabs->GetSize(); ++i) { 105 for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
108 base::DictionaryValue* result_tab = NULL; 106 base::DictionaryValue* result_tab = NULL;
109 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); 107 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
110 EXPECT_EQ(focused_window_id, 108 EXPECT_EQ(focused_window_id,
111 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey)); 109 api_test_utils::GetInteger(result_tab, keys::kWindowIdKey));
112 } 110 }
(...skipping 17 matching lines...) Expand all
130 } 128 }
131 129
132 #if defined(OS_WIN) // http://crbug.com/154081 && http://crbug.com/171080 130 #if defined(OS_WIN) // http://crbug.com/154081 && http://crbug.com/171080
133 #define MAYBE_TabCurrentWindow DISABLED_TabCurrentWindow 131 #define MAYBE_TabCurrentWindow DISABLED_TabCurrentWindow
134 #else 132 #else
135 #define MAYBE_TabCurrentWindow TabCurrentWindow 133 #define MAYBE_TabCurrentWindow TabCurrentWindow
136 #endif 134 #endif
137 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabCurrentWindow) { 135 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_TabCurrentWindow) {
138 ASSERT_TRUE(RunExtensionTest("tabs/current_window")) << message_; 136 ASSERT_TRUE(RunExtensionTest("tabs/current_window")) << message_;
139 } 137 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_event_router.cc ('k') | chrome/browser/extensions/api/tabs/tabs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698