| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/gtk/options/cookies_view.h" | 5 #include "chrome/browser/gtk/options/cookies_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| 11 | 11 |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 13 #include "chrome/browser/net/url_request_context_getter.h" | 14 #include "chrome/browser/net/url_request_context_getter.h" |
| 14 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
| 15 #include "net/url_request/url_request_context.h" | 16 #include "net/url_request/url_request_context.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 class CookiesViewTest : public testing::Test { | 19 class CookiesViewTest : public testing::Test { |
| 19 public: | 20 public: |
| 20 CookiesViewTest() : io_thread_(ChromeThread::IO, &message_loop_) { | 21 CookiesViewTest() : io_thread_(ChromeThread::IO, &message_loop_) { |
| 21 } | 22 } |
| 22 | 23 |
| 23 virtual ~CookiesViewTest() { | 24 virtual ~CookiesViewTest() { |
| 24 } | 25 } |
| 25 | 26 |
| 26 virtual void SetUp() { | 27 virtual void SetUp() { |
| 27 profile_.reset(new TestingProfile()); | 28 profile_.reset(new TestingProfile()); |
| 28 profile_->CreateRequestContext(); | 29 profile_->CreateRequestContext(); |
| 30 mock_browsing_data_helper_ = new MockBrowsingDataLocalStorageHelper( |
| 31 profile_.get()); |
| 29 } | 32 } |
| 30 | 33 |
| 31 void CheckDetailsSensitivity(gboolean expected, | 34 void CheckDetailsSensitivity(gboolean expected_cookies, |
| 35 gboolean expected_local_storage, |
| 32 const CookiesView& cookies_view) { | 36 const CookiesView& cookies_view) { |
| 33 EXPECT_EQ(expected, | 37 // Cookies |
| 38 EXPECT_EQ(expected_cookies, |
| 34 GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_)); | 39 GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_)); |
| 35 EXPECT_EQ(expected, | 40 EXPECT_EQ(expected_cookies, |
| 36 GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_)); | 41 GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_)); |
| 37 EXPECT_EQ(expected, | 42 EXPECT_EQ(expected_cookies, |
| 38 GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_)); | 43 GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_)); |
| 39 EXPECT_EQ(expected, | 44 EXPECT_EQ(expected_cookies, |
| 40 GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_)); | 45 GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_)); |
| 41 EXPECT_EQ(expected, | 46 EXPECT_EQ(expected_cookies, |
| 42 GTK_WIDGET_SENSITIVE(cookies_view.cookie_send_for_entry_)); | 47 GTK_WIDGET_SENSITIVE(cookies_view.cookie_send_for_entry_)); |
| 43 EXPECT_EQ(expected, | 48 EXPECT_EQ(expected_cookies, |
| 44 GTK_WIDGET_SENSITIVE(cookies_view.cookie_created_entry_)); | 49 GTK_WIDGET_SENSITIVE(cookies_view.cookie_created_entry_)); |
| 45 EXPECT_EQ(expected, | 50 EXPECT_EQ(expected_cookies, |
| 46 GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_)); | 51 GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_)); |
| 52 // Local Storage |
| 53 EXPECT_EQ(expected_local_storage, |
| 54 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_)); |
| 55 EXPECT_EQ(expected_local_storage, |
| 56 GTK_WIDGET_SENSITIVE(cookies_view.local_storage_size_entry_)); |
| 57 EXPECT_EQ(expected_local_storage, |
| 58 GTK_WIDGET_SENSITIVE( |
| 59 cookies_view.local_storage_last_modified_entry_)); |
| 60 |
| 47 } | 61 } |
| 48 | 62 |
| 49 // Get the cookie names in the cookie list, as a comma seperated string. | 63 // Get the cookie names in the cookie list, as a comma seperated string. |
| 50 // (Note that the CookieMonster cookie list is sorted by domain.) | 64 // (Note that the CookieMonster cookie list is sorted by domain.) |
| 51 // Ex: | 65 // Ex: |
| 52 // monster->SetCookie(GURL("http://b"), "X=1") | 66 // monster->SetCookie(GURL("http://b"), "X=1") |
| 53 // monster->SetCookie(GURL("http://a"), "Y=1") | 67 // monster->SetCookie(GURL("http://a"), "Y=1") |
| 54 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | 68 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); |
| 55 std::string GetMonsterCookies(net::CookieMonster* monster) { | 69 std::string GetMonsterCookies(net::CookieMonster* monster) { |
| 56 std::vector<std::string> parts; | 70 std::vector<std::string> parts; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 155 } |
| 142 } | 156 } |
| 143 return result; | 157 return result; |
| 144 } | 158 } |
| 145 | 159 |
| 146 protected: | 160 protected: |
| 147 MessageLoop message_loop_; | 161 MessageLoop message_loop_; |
| 148 ChromeThread io_thread_; | 162 ChromeThread io_thread_; |
| 149 | 163 |
| 150 scoped_ptr<TestingProfile> profile_; | 164 scoped_ptr<TestingProfile> profile_; |
| 165 scoped_refptr<MockBrowsingDataLocalStorageHelper> mock_browsing_data_helper_; |
| 151 }; | 166 }; |
| 152 | 167 |
| 153 TEST_F(CookiesViewTest, Empty) { | 168 TEST_F(CookiesViewTest, Empty) { |
| 154 CookiesView cookies_view(profile_.get()); | 169 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 155 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 170 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 156 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 171 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 157 CheckDetailsSensitivity(FALSE, cookies_view); | 172 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 158 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | 173 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
| 159 } | 174 } |
| 160 | 175 |
| 161 TEST_F(CookiesViewTest, Noop) { | 176 TEST_F(CookiesViewTest, Noop) { |
| 162 net::CookieMonster* monster = profile_->GetCookieMonster(); | 177 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 163 monster->SetCookie(GURL("http://foo0"), "C=1"); | 178 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 164 monster->SetCookie(GURL("http://foo0"), "D=1"); | 179 monster->SetCookie(GURL("http://foo0"), "D=1"); |
| 165 monster->SetCookie(GURL("http://foo1"), "B=1"); | 180 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 166 monster->SetCookie(GURL("http://foo1"), "A=1"); | 181 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 167 monster->SetCookie(GURL("http://foo1"), "E=1"); | 182 monster->SetCookie(GURL("http://foo1"), "E=1"); |
| 168 monster->SetCookie(GURL("http://foo2"), "G=1"); | 183 monster->SetCookie(GURL("http://foo2"), "G=1"); |
| 169 monster->SetCookie(GURL("http://foo2"), "X=1"); | 184 monster->SetCookie(GURL("http://foo2"), "X=1"); |
| 170 CookiesView cookies_view(profile_.get()); | 185 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 186 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 187 mock_browsing_data_helper_->Notify(); |
| 171 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 188 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 172 "foo1,_Cookies,__A,__B,__E," | 189 "foo1,_Cookies,__A,__B,__E," |
| 173 "foo2,_Cookies,__G,__X", | 190 "foo2,_Cookies,__G,__X," |
| 191 "host1,_Local Storage,__origin1," |
| 192 "host2,_Local Storage,__origin2", |
| 174 GetDisplayedCookies(cookies_view).c_str()); | 193 GetDisplayedCookies(cookies_view).c_str()); |
| 175 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 194 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 176 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 195 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 177 CheckDetailsSensitivity(FALSE, cookies_view); | 196 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 178 } | 197 } |
| 179 | 198 |
| 180 TEST_F(CookiesViewTest, RemoveAll) { | 199 TEST_F(CookiesViewTest, RemoveAll) { |
| 181 net::CookieMonster* monster = profile_->GetCookieMonster(); | 200 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 182 monster->SetCookie(GURL("http://foo"), "A=1"); | 201 monster->SetCookie(GURL("http://foo"), "A=1"); |
| 183 monster->SetCookie(GURL("http://foo2"), "B=1"); | 202 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 184 CookiesView cookies_view(profile_.get()); | 203 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 204 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 205 mock_browsing_data_helper_->Notify(); |
| 185 | 206 |
| 186 // Reset the selection of the first row. | 207 // Reset the selection of the first row. |
| 187 gtk_tree_selection_unselect_all(cookies_view.selection_); | 208 gtk_tree_selection_unselect_all(cookies_view.selection_); |
| 188 | 209 |
| 189 { | 210 { |
| 190 SCOPED_TRACE("Before removing"); | 211 SCOPED_TRACE("Before removing"); |
| 191 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 212 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 192 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 213 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 193 CheckDetailsSensitivity(FALSE, cookies_view); | 214 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 194 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B", | 215 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," |
| 216 "host1,_Local Storage,__origin1," |
| 217 "host2,_Local Storage,__origin2", |
| 195 GetDisplayedCookies(cookies_view).c_str()); | 218 GetDisplayedCookies(cookies_view).c_str()); |
| 196 } | 219 } |
| 197 | 220 |
| 198 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | 221 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); |
| 199 { | 222 { |
| 200 SCOPED_TRACE("After removing"); | 223 SCOPED_TRACE("After removing"); |
| 201 EXPECT_EQ(0u, monster->GetAllCookies().size()); | 224 EXPECT_EQ(0u, monster->GetAllCookies().size()); |
| 202 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 225 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 203 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 226 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 204 CheckDetailsSensitivity(FALSE, cookies_view); | 227 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 205 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | 228 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
| 229 EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_); |
| 206 } | 230 } |
| 207 } | 231 } |
| 208 | 232 |
| 209 TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { | 233 TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { |
| 210 net::CookieMonster* monster = profile_->GetCookieMonster(); | 234 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 211 monster->SetCookie(GURL("http://foo"), "A=1"); | 235 monster->SetCookie(GURL("http://foo"), "A=1"); |
| 212 monster->SetCookie(GURL("http://foo2"), "B=1"); | 236 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 213 CookiesView cookies_view(profile_.get()); | 237 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 238 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 239 mock_browsing_data_helper_->Notify(); |
| 214 | 240 |
| 215 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | 241 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
| 216 EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | 242 EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); |
| 217 { | 243 { |
| 218 SCOPED_TRACE("Before removing"); | 244 SCOPED_TRACE("Before removing"); |
| 219 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 245 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 220 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 246 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 221 CheckDetailsSensitivity(FALSE, cookies_view); | 247 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 222 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B", | 248 EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," |
| 249 "host1,_Local Storage,__origin1," |
| 250 "host2,_Local Storage,__origin2", |
| 223 GetDisplayedCookies(cookies_view).c_str()); | 251 GetDisplayedCookies(cookies_view).c_str()); |
| 224 } | 252 } |
| 225 | 253 |
| 226 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | 254 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); |
| 227 { | 255 { |
| 228 SCOPED_TRACE("After removing"); | 256 SCOPED_TRACE("After removing"); |
| 229 EXPECT_EQ(0u, monster->GetAllCookies().size()); | 257 EXPECT_EQ(0u, monster->GetAllCookies().size()); |
| 230 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 258 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 231 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 259 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 232 CheckDetailsSensitivity(FALSE, cookies_view); | 260 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 233 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | 261 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
| 234 EXPECT_EQ(0, | 262 EXPECT_EQ(0, |
| 235 gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | 263 gtk_tree_selection_count_selected_rows(cookies_view.selection_)); |
| 264 EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_); |
| 236 } | 265 } |
| 237 } | 266 } |
| 238 | 267 |
| 239 TEST_F(CookiesViewTest, Remove) { | 268 TEST_F(CookiesViewTest, Remove) { |
| 240 net::CookieMonster* monster = profile_->GetCookieMonster(); | 269 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 241 monster->SetCookie(GURL("http://foo1"), "A=1"); | 270 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 242 monster->SetCookie(GURL("http://foo2"), "B=1"); | 271 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 243 monster->SetCookie(GURL("http://foo2"), "C=1"); | 272 monster->SetCookie(GURL("http://foo2"), "C=1"); |
| 244 CookiesView cookies_view(profile_.get()); | 273 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 274 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 275 mock_browsing_data_helper_->Notify(); |
| 245 | 276 |
| 246 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | 277 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
| 247 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | 278 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); |
| 248 | 279 |
| 249 { | 280 { |
| 250 SCOPED_TRACE("First selection"); | 281 SCOPED_TRACE("First selection"); |
| 251 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 282 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 252 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 283 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 253 CheckDetailsSensitivity(TRUE, cookies_view); | 284 CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
| 254 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C", | 285 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," |
| 286 "host1,_Local Storage,__origin1," |
| 287 "host2,_Local Storage,__origin2", |
| 255 GetDisplayedCookies(cookies_view).c_str()); | 288 GetDisplayedCookies(cookies_view).c_str()); |
| 256 } | 289 } |
| 257 | 290 |
| 258 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 291 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 259 | 292 |
| 260 { | 293 { |
| 261 SCOPED_TRACE("First selection removed"); | 294 SCOPED_TRACE("First selection removed"); |
| 262 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 295 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 263 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C", | 296 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," |
| 297 "host1,_Local Storage,__origin1," |
| 298 "host2,_Local Storage,__origin2", |
| 264 GetDisplayedCookies(cookies_view).c_str()); | 299 GetDisplayedCookies(cookies_view).c_str()); |
| 265 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 300 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 266 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 301 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 267 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); | 302 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); |
| 268 CheckDetailsSensitivity(TRUE, cookies_view); | 303 CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
| 269 } | 304 } |
| 270 | 305 |
| 271 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 306 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 272 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 307 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 273 | 308 |
| 274 { | 309 { |
| 275 SCOPED_TRACE("Second selection"); | 310 SCOPED_TRACE("Second selection"); |
| 276 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); | 311 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); |
| 277 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies", | 312 EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies," |
| 313 "host1,_Local Storage,__origin1," |
| 314 "host2,_Local Storage,__origin2", |
| 278 GetDisplayedCookies(cookies_view).c_str()); | 315 GetDisplayedCookies(cookies_view).c_str()); |
| 279 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 316 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 280 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 317 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 281 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); | 318 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); |
| 282 CheckDetailsSensitivity(FALSE, cookies_view); | 319 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 283 } | 320 } |
| 284 | 321 |
| 285 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | 322 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
| 286 EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies", | 323 EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies," |
| 324 "host1,_Local Storage,__origin1," |
| 325 "host2,_Local Storage,__origin2", |
| 287 GetDisplayedCookies(cookies_view).c_str()); | 326 GetDisplayedCookies(cookies_view).c_str()); |
| 288 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); | 327 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); |
| 289 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 328 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 290 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 329 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 291 | 330 |
| 292 { | 331 { |
| 293 SCOPED_TRACE("Second selection removed"); | 332 SCOPED_TRACE("Second selection removed"); |
| 294 EXPECT_EQ(0u, monster->GetAllCookies().size()); | 333 EXPECT_EQ(0u, monster->GetAllCookies().size()); |
| 295 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 334 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 296 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 335 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 297 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); | 336 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); |
| 298 CheckDetailsSensitivity(FALSE, cookies_view); | 337 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 299 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies", | 338 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
| 339 "host1,_Local Storage,__origin1," |
| 340 "host2,_Local Storage,__origin2", |
| 300 GetDisplayedCookies(cookies_view).c_str()); | 341 GetDisplayedCookies(cookies_view).c_str()); |
| 301 } | 342 } |
| 343 |
| 344 ASSERT_TRUE(ExpandByPath(cookies_view, "2")); |
| 345 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
| 346 "host1,+Local Storage,++origin1," |
| 347 "host2,_Local Storage,__origin2", |
| 348 GetDisplayedCookies(cookies_view).c_str()); |
| 349 ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); |
| 350 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 351 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 352 |
| 353 { |
| 354 SCOPED_TRACE("Third selection removed"); |
| 355 EXPECT_EQ(0u, monster->GetAllCookies().size()); |
| 356 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 357 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 358 EXPECT_STREQ("2:0", GetSelectedPath(cookies_view).c_str()); |
| 359 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 360 EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies," |
| 361 "host1,+Local Storage," |
| 362 "host2,_Local Storage,__origin2", |
| 363 GetDisplayedCookies(cookies_view).c_str()); |
| 364 EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
| 365 FilePath(FILE_PATH_LITERAL("file1"))); |
| 366 } |
| 302 } | 367 } |
| 303 | 368 |
| 304 TEST_F(CookiesViewTest, RemoveCookiesByDomain) { | 369 TEST_F(CookiesViewTest, RemoveCookiesByDomain) { |
| 305 net::CookieMonster* monster = profile_->GetCookieMonster(); | 370 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 306 monster->SetCookie(GURL("http://foo0"), "C=1"); | 371 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 307 monster->SetCookie(GURL("http://foo0"), "D=1"); | 372 monster->SetCookie(GURL("http://foo0"), "D=1"); |
| 308 monster->SetCookie(GURL("http://foo1"), "B=1"); | 373 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 309 monster->SetCookie(GURL("http://foo1"), "A=1"); | 374 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 310 monster->SetCookie(GURL("http://foo1"), "E=1"); | 375 monster->SetCookie(GURL("http://foo1"), "E=1"); |
| 311 monster->SetCookie(GURL("http://foo2"), "G=1"); | 376 monster->SetCookie(GURL("http://foo2"), "G=1"); |
| 312 monster->SetCookie(GURL("http://foo2"), "X=1"); | 377 monster->SetCookie(GURL("http://foo2"), "X=1"); |
| 313 CookiesView cookies_view(profile_.get()); | 378 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 379 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 380 mock_browsing_data_helper_->Notify(); |
| 381 |
| 314 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 382 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 315 "foo1,_Cookies,__A,__B,__E," | 383 "foo1,_Cookies,__A,__B,__E," |
| 316 "foo2,_Cookies,__G,__X", | 384 "foo2,_Cookies,__G,__X," |
| 385 "host1,_Local Storage,__origin1," |
| 386 "host2,_Local Storage,__origin2", |
| 317 GetDisplayedCookies(cookies_view).c_str()); | 387 GetDisplayedCookies(cookies_view).c_str()); |
| 318 | 388 |
| 319 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | 389 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
| 320 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 390 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 321 "foo1,+Cookies,++A,++B,++E," | 391 "foo1,+Cookies,++A,++B,++E," |
| 322 "foo2,_Cookies,__G,__X", | 392 "foo2,_Cookies,__G,__X," |
| 393 "host1,_Local Storage,__origin1," |
| 394 "host2,_Local Storage,__origin2", |
| 323 GetDisplayedCookies(cookies_view).c_str()); | 395 GetDisplayedCookies(cookies_view).c_str()); |
| 324 ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); | 396 ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); |
| 325 | 397 |
| 326 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 398 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 327 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 399 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 328 | 400 |
| 329 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 401 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 330 | 402 |
| 331 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); | 403 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); |
| 332 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 404 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 333 "foo1," | 405 "foo1," |
| 334 "foo2,_Cookies,__G,__X", | 406 "foo2,_Cookies,__G,__X," |
| 407 "host1,_Local Storage,__origin1," |
| 408 "host2,_Local Storage,__origin2", |
| 335 GetDisplayedCookies(cookies_view).c_str()); | 409 GetDisplayedCookies(cookies_view).c_str()); |
| 336 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 410 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 337 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 411 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 338 EXPECT_STREQ("1", GetSelectedPath(cookies_view).c_str()); | 412 EXPECT_STREQ("1", GetSelectedPath(cookies_view).c_str()); |
| 339 | 413 |
| 340 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | 414 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
| 341 EXPECT_STREQ("foo0,+Cookies,++C,++D," | 415 EXPECT_STREQ("foo0,+Cookies,++C,++D," |
| 342 "foo1," | 416 "foo1," |
| 343 "foo2,_Cookies,__G,__X", | 417 "foo2,_Cookies,__G,__X," |
| 418 "host1,_Local Storage,__origin1," |
| 419 "host2,_Local Storage,__origin2", |
| 344 GetDisplayedCookies(cookies_view).c_str()); | 420 GetDisplayedCookies(cookies_view).c_str()); |
| 345 ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); | 421 ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); |
| 346 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 422 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 347 | 423 |
| 348 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | 424 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
| 349 EXPECT_STREQ("foo0," | 425 EXPECT_STREQ("foo0," |
| 350 "foo1," | 426 "foo1," |
| 351 "foo2,_Cookies,__G,__X", | 427 "foo2,_Cookies,__G,__X," |
| 428 "host1,_Local Storage,__origin1," |
| 429 "host2,_Local Storage,__origin2", |
| 352 GetDisplayedCookies(cookies_view).c_str()); | 430 GetDisplayedCookies(cookies_view).c_str()); |
| 353 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 431 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 354 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 432 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 355 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | 433 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
| 356 | 434 |
| 357 ASSERT_TRUE(ExpandByPath(cookies_view, "2")); | 435 ASSERT_TRUE(ExpandByPath(cookies_view, "2")); |
| 358 EXPECT_STREQ("foo0," | 436 EXPECT_STREQ("foo0," |
| 359 "foo1," | 437 "foo1," |
| 360 "foo2,+Cookies,++G,++X", | 438 "foo2,+Cookies,++G,++X," |
| 439 "host1,_Local Storage,__origin1," |
| 440 "host2,_Local Storage,__origin2", |
| 361 GetDisplayedCookies(cookies_view).c_str()); | 441 GetDisplayedCookies(cookies_view).c_str()); |
| 362 ASSERT_TRUE(SelectByPath(cookies_view, "2:0")); | 442 ASSERT_TRUE(SelectByPath(cookies_view, "2:0")); |
| 363 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 443 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 364 | 444 |
| 365 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | 445 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 366 EXPECT_STREQ("foo0," | 446 EXPECT_STREQ("foo0," |
| 367 "foo1," | 447 "foo1," |
| 368 "foo2", | 448 "foo2," |
| 449 "host1,_Local Storage,__origin1," |
| 450 "host2,_Local Storage,__origin2", |
| 369 GetDisplayedCookies(cookies_view).c_str()); | 451 GetDisplayedCookies(cookies_view).c_str()); |
| 370 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 452 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 371 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 453 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 372 EXPECT_STREQ("2", GetSelectedPath(cookies_view).c_str()); | 454 EXPECT_STREQ("2", GetSelectedPath(cookies_view).c_str()); |
| 455 |
| 456 ASSERT_TRUE(ExpandByPath(cookies_view, "3")); |
| 457 EXPECT_STREQ("foo0," |
| 458 "foo1," |
| 459 "foo2," |
| 460 "host1,+Local Storage,++origin1," |
| 461 "host2,_Local Storage,__origin2", |
| 462 GetDisplayedCookies(cookies_view).c_str()); |
| 463 ASSERT_TRUE(SelectByPath(cookies_view, "3:0")); |
| 464 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 465 |
| 466 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 467 EXPECT_STREQ("foo0," |
| 468 "foo1," |
| 469 "foo2," |
| 470 "host1," |
| 471 "host2,_Local Storage,__origin2", |
| 472 GetDisplayedCookies(cookies_view).c_str()); |
| 473 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 474 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 475 EXPECT_STREQ("3", GetSelectedPath(cookies_view).c_str()); |
| 476 EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
| 477 FilePath(FILE_PATH_LITERAL("file1"))); |
| 373 } | 478 } |
| 374 | 479 |
| 375 TEST_F(CookiesViewTest, RemoveByDomain) { | 480 TEST_F(CookiesViewTest, RemoveByDomain) { |
| 376 net::CookieMonster* monster = profile_->GetCookieMonster(); | 481 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 377 monster->SetCookie(GURL("http://foo0"), "C=1"); | 482 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 378 monster->SetCookie(GURL("http://foo0"), "D=1"); | 483 monster->SetCookie(GURL("http://foo0"), "D=1"); |
| 379 monster->SetCookie(GURL("http://foo1"), "B=1"); | 484 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 380 monster->SetCookie(GURL("http://foo1"), "A=1"); | 485 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 381 monster->SetCookie(GURL("http://foo1"), "E=1"); | 486 monster->SetCookie(GURL("http://foo1"), "E=1"); |
| 382 monster->SetCookie(GURL("http://foo2"), "G=1"); | 487 monster->SetCookie(GURL("http://foo2"), "G=1"); |
| 383 monster->SetCookie(GURL("http://foo2"), "X=1"); | 488 monster->SetCookie(GURL("http://foo2"), "X=1"); |
| 384 CookiesView cookies_view(profile_.get()); | 489 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 490 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 491 mock_browsing_data_helper_->Notify(); |
| 492 |
| 385 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 493 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 386 "foo1,_Cookies,__A,__B,__E," | 494 "foo1,_Cookies,__A,__B,__E," |
| 387 "foo2,_Cookies,__G,__X", | 495 "foo2,_Cookies,__G,__X," |
| 496 "host1,_Local Storage,__origin1," |
| 497 "host2,_Local Storage,__origin2", |
| 388 GetDisplayedCookies(cookies_view).c_str()); | 498 GetDisplayedCookies(cookies_view).c_str()); |
| 389 | 499 |
| 390 ASSERT_TRUE(SelectByPath(cookies_view, "1")); | 500 ASSERT_TRUE(SelectByPath(cookies_view, "1")); |
| 391 | 501 |
| 392 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 502 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 393 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 503 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 394 | 504 |
| 395 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 505 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 396 | 506 |
| 397 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); | 507 EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str()); |
| 398 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 508 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 399 "foo2,_Cookies,__G,__X", | 509 "foo2,_Cookies,__G,__X," |
| 510 "host1,_Local Storage,__origin1," |
| 511 "host2,_Local Storage,__origin2", |
| 400 GetDisplayedCookies(cookies_view).c_str()); | 512 GetDisplayedCookies(cookies_view).c_str()); |
| 401 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 513 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 402 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 514 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 403 EXPECT_STREQ("1", GetSelectedPath(cookies_view).c_str()); | 515 EXPECT_STREQ("1", GetSelectedPath(cookies_view).c_str()); |
| 404 | 516 |
| 405 ASSERT_TRUE(SelectByPath(cookies_view, "0")); | 517 ASSERT_TRUE(SelectByPath(cookies_view, "0")); |
| 406 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 518 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 407 | 519 |
| 408 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | 520 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
| 409 EXPECT_STREQ("foo2,_Cookies,__G,__X", | 521 EXPECT_STREQ("foo2,_Cookies,__G,__X," |
| 522 "host1,_Local Storage,__origin1," |
| 523 "host2,_Local Storage,__origin2", |
| 410 GetDisplayedCookies(cookies_view).c_str()); | 524 GetDisplayedCookies(cookies_view).c_str()); |
| 411 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 525 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 412 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 526 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 413 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); | 527 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
| 414 | 528 |
| 415 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 529 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 416 | 530 |
| 417 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | 531 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 418 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | 532 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 533 "host2,_Local Storage,__origin2", |
| 534 GetDisplayedCookies(cookies_view).c_str()); |
| 535 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 536 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 537 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
| 538 |
| 539 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 540 |
| 541 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 542 EXPECT_STREQ("host2,_Local Storage,__origin2", |
| 543 GetDisplayedCookies(cookies_view).c_str()); |
| 544 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 545 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 546 EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
| 547 FilePath(FILE_PATH_LITERAL("file1"))); |
| 548 EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str()); |
| 549 |
| 550 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 551 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 552 EXPECT_STREQ("", |
| 553 GetDisplayedCookies(cookies_view).c_str()); |
| 419 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 554 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 420 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 555 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 556 EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ == |
| 557 FilePath(FILE_PATH_LITERAL("file2"))); |
| 558 |
| 421 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); | 559 EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_)); |
| 422 } | 560 } |
| 423 | 561 |
| 424 TEST_F(CookiesViewTest, RemoveDefaultSelection) { | 562 TEST_F(CookiesViewTest, RemoveDefaultSelection) { |
| 425 net::CookieMonster* monster = profile_->GetCookieMonster(); | 563 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 426 monster->SetCookie(GURL("http://foo0"), "C=1"); | 564 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 427 monster->SetCookie(GURL("http://foo0"), "D=1"); | 565 monster->SetCookie(GURL("http://foo0"), "D=1"); |
| 428 monster->SetCookie(GURL("http://foo1"), "B=1"); | 566 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 429 monster->SetCookie(GURL("http://foo1"), "A=1"); | 567 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 430 monster->SetCookie(GURL("http://foo1"), "E=1"); | 568 monster->SetCookie(GURL("http://foo1"), "E=1"); |
| 431 monster->SetCookie(GURL("http://foo2"), "G=1"); | 569 monster->SetCookie(GURL("http://foo2"), "G=1"); |
| 432 monster->SetCookie(GURL("http://foo2"), "X=1"); | 570 monster->SetCookie(GURL("http://foo2"), "X=1"); |
| 433 CookiesView cookies_view(profile_.get()); | 571 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 572 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 573 mock_browsing_data_helper_->Notify(); |
| 574 |
| 434 EXPECT_STREQ("foo0,_Cookies,__C,__D," | 575 EXPECT_STREQ("foo0,_Cookies,__C,__D," |
| 435 "foo1,_Cookies,__A,__B,__E," | 576 "foo1,_Cookies,__A,__B,__E," |
| 436 "foo2,_Cookies,__G,__X", | 577 "foo2,_Cookies,__G,__X," |
| 578 "host1,_Local Storage,__origin1," |
| 579 "host2,_Local Storage,__origin2", |
| 437 GetDisplayedCookies(cookies_view).c_str()); | 580 GetDisplayedCookies(cookies_view).c_str()); |
| 438 | 581 |
| 439 | 582 |
| 440 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 583 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 441 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 584 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 442 | 585 |
| 443 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 586 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 444 | 587 |
| 445 EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str()); | 588 EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str()); |
| 446 EXPECT_STREQ("foo1,_Cookies,__A,__B,__E," | 589 EXPECT_STREQ("foo1,_Cookies,__A,__B,__E," |
| 447 "foo2,_Cookies,__G,__X", | 590 "foo2,_Cookies,__G,__X," |
| 591 "host1,_Local Storage,__origin1," |
| 592 "host2,_Local Storage,__origin2", |
| 448 GetDisplayedCookies(cookies_view).c_str()); | 593 GetDisplayedCookies(cookies_view).c_str()); |
| 449 | 594 |
| 450 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 595 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 451 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 596 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 452 | 597 |
| 453 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 598 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 454 | 599 |
| 455 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); | 600 EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str()); |
| 456 EXPECT_STREQ("foo2,_Cookies,__G,__X", | 601 EXPECT_STREQ("foo2,_Cookies,__G,__X," |
| 602 "host1,_Local Storage,__origin1," |
| 603 "host2,_Local Storage,__origin2", |
| 457 GetDisplayedCookies(cookies_view).c_str()); | 604 GetDisplayedCookies(cookies_view).c_str()); |
| 458 | 605 |
| 459 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 606 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 460 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 607 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 461 | 608 |
| 462 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 609 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 463 | 610 |
| 464 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | 611 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 612 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 613 "host2,_Local Storage,__origin2", |
| 614 GetDisplayedCookies(cookies_view).c_str()); |
| 615 |
| 616 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 617 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 618 |
| 619 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 620 |
| 621 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 622 EXPECT_STREQ("host2,_Local Storage,__origin2", |
| 623 GetDisplayedCookies(cookies_view).c_str()); |
| 624 |
| 625 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 626 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 627 |
| 628 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 629 |
| 630 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 465 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); | 631 EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str()); |
| 466 | 632 |
| 467 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 633 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 468 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 634 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 469 } | 635 } |
| 470 | 636 |
| 471 TEST_F(CookiesViewTest, Filter) { | 637 TEST_F(CookiesViewTest, Filter) { |
| 472 net::CookieMonster* monster = profile_->GetCookieMonster(); | 638 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 473 monster->SetCookie(GURL("http://foo0"), "C=1"); | 639 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 474 monster->SetCookie(GURL("http://bar0"), "D=1"); | 640 monster->SetCookie(GURL("http://bar0"), "D=1"); |
| 475 monster->SetCookie(GURL("http://foo1"), "B=1"); | 641 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 476 monster->SetCookie(GURL("http://bar1"), "A=1"); | 642 monster->SetCookie(GURL("http://bar1"), "A=1"); |
| 477 CookiesView cookies_view(profile_.get()); | 643 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 644 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 645 mock_browsing_data_helper_->Notify(); |
| 646 |
| 478 EXPECT_STREQ("bar0,_Cookies,__D," | 647 EXPECT_STREQ("bar0,_Cookies,__D," |
| 479 "bar1,_Cookies,__A," | 648 "bar1,_Cookies,__A," |
| 480 "foo0,_Cookies,__C," | 649 "foo0,_Cookies,__C," |
| 481 "foo1,_Cookies,__B", | 650 "foo1,_Cookies,__B," |
| 651 "host1,_Local Storage,__origin1," |
| 652 "host2,_Local Storage,__origin2", |
| 482 GetDisplayedCookies(cookies_view).c_str()); | 653 GetDisplayedCookies(cookies_view).c_str()); |
| 483 | 654 |
| 484 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 655 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 485 | 656 |
| 486 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | 657 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); |
| 487 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 658 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 488 // Entering text doesn't immediately filter the results. | 659 // Entering text doesn't immediately filter the results. |
| 489 EXPECT_STREQ("bar0,_Cookies,__D," | 660 EXPECT_STREQ("bar0,_Cookies,__D," |
| 490 "bar1,_Cookies,__A," | 661 "bar1,_Cookies,__A," |
| 491 "foo0,_Cookies,__C," | 662 "foo0,_Cookies,__C," |
| 492 "foo1,_Cookies,__B", | 663 "foo1,_Cookies,__B," |
| 664 "host1,_Local Storage,__origin1," |
| 665 "host2,_Local Storage,__origin2", |
| 493 GetDisplayedCookies(cookies_view).c_str()); | 666 GetDisplayedCookies(cookies_view).c_str()); |
| 494 | 667 |
| 495 // Results are filtered immediately if you activate (hit enter in the entry). | 668 // Results are filtered immediately if you activate (hit enter in the entry). |
| 496 gtk_widget_activate(cookies_view.filter_entry_); | 669 gtk_widget_activate(cookies_view.filter_entry_); |
| 497 EXPECT_STREQ("bar0,_Cookies,__D," | 670 EXPECT_STREQ("bar0,_Cookies,__D," |
| 498 "bar1,_Cookies,__A", | 671 "bar1,_Cookies,__A", |
| 499 GetDisplayedCookies(cookies_view).c_str()); | 672 GetDisplayedCookies(cookies_view).c_str()); |
| 500 | 673 |
| 501 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | 674 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); |
| 502 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 675 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 503 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | 676 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); |
| 504 EXPECT_STREQ("bar0,_Cookies,__D," | 677 EXPECT_STREQ("bar0,_Cookies,__D," |
| 505 "bar1,_Cookies,__A," | 678 "bar1,_Cookies,__A," |
| 506 "foo0,_Cookies,__C," | 679 "foo0,_Cookies,__C," |
| 507 "foo1,_Cookies,__B", | 680 "foo1,_Cookies,__B," |
| 681 "host1,_Local Storage,__origin1," |
| 682 "host2,_Local Storage,__origin2", |
| 683 GetDisplayedCookies(cookies_view).c_str()); |
| 684 |
| 685 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); |
| 686 gtk_widget_activate(cookies_view.filter_entry_); |
| 687 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 688 "host2,_Local Storage,__origin2", |
| 508 GetDisplayedCookies(cookies_view).c_str()); | 689 GetDisplayedCookies(cookies_view).c_str()); |
| 509 } | 690 } |
| 510 | 691 |
| 511 TEST_F(CookiesViewTest, FilterRemoveAll) { | 692 TEST_F(CookiesViewTest, FilterRemoveAll) { |
| 512 net::CookieMonster* monster = profile_->GetCookieMonster(); | 693 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 513 monster->SetCookie(GURL("http://foo0"), "C=1"); | 694 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 514 monster->SetCookie(GURL("http://bar0"), "D=1"); | 695 monster->SetCookie(GURL("http://bar0"), "D=1"); |
| 515 monster->SetCookie(GURL("http://foo1"), "B=1"); | 696 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 516 monster->SetCookie(GURL("http://bar1"), "A=1"); | 697 monster->SetCookie(GURL("http://bar1"), "A=1"); |
| 517 CookiesView cookies_view(profile_.get()); | 698 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 699 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 700 mock_browsing_data_helper_->Notify(); |
| 701 |
| 518 EXPECT_STREQ("bar0,_Cookies,__D," | 702 EXPECT_STREQ("bar0,_Cookies,__D," |
| 519 "bar1,_Cookies,__A," | 703 "bar1,_Cookies,__A," |
| 520 "foo0,_Cookies,__C," | 704 "foo0,_Cookies,__C," |
| 521 "foo1,_Cookies,__B", | 705 "foo1,_Cookies,__B," |
| 706 "host1,_Local Storage,__origin1," |
| 707 "host2,_Local Storage,__origin2", |
| 522 GetDisplayedCookies(cookies_view).c_str()); | 708 GetDisplayedCookies(cookies_view).c_str()); |
| 523 | 709 |
| 524 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 710 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 525 | 711 |
| 526 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | 712 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); |
| 527 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 713 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 528 // Entering text doesn't immediately filter the results. | 714 // Entering text doesn't immediately filter the results. |
| 529 EXPECT_STREQ("bar0,_Cookies,__D," | 715 EXPECT_STREQ("bar0,_Cookies,__D," |
| 530 "bar1,_Cookies,__A," | 716 "bar1,_Cookies,__A," |
| 531 "foo0,_Cookies,__C," | 717 "foo0,_Cookies,__C," |
| 532 "foo1,_Cookies,__B", | 718 "foo1,_Cookies,__B," |
| 719 "host1,_Local Storage,__origin1," |
| 720 "host2,_Local Storage,__origin2", |
| 533 GetDisplayedCookies(cookies_view).c_str()); | 721 GetDisplayedCookies(cookies_view).c_str()); |
| 534 | 722 |
| 535 // Results are filtered immediately if you activate (hit enter in the entry). | 723 // Results are filtered immediately if you activate (hit enter in the entry). |
| 536 gtk_widget_activate(cookies_view.filter_entry_); | 724 gtk_widget_activate(cookies_view.filter_entry_); |
| 537 EXPECT_STREQ("bar0,_Cookies,__D," | 725 EXPECT_STREQ("bar0,_Cookies,__D," |
| 538 "bar1,_Cookies,__A", | 726 "bar1,_Cookies,__A", |
| 539 GetDisplayedCookies(cookies_view).c_str()); | 727 GetDisplayedCookies(cookies_view).c_str()); |
| 540 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 728 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 541 | 729 |
| 542 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); | 730 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_all_button_)); |
| 543 | 731 |
| 544 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 732 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 545 EXPECT_STREQ("", | 733 EXPECT_STREQ("", |
| 546 GetDisplayedCookies(cookies_view).c_str()); | 734 GetDisplayedCookies(cookies_view).c_str()); |
| 547 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 735 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 548 | 736 |
| 549 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | 737 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); |
| 550 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 738 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 551 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | 739 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); |
| 552 EXPECT_STREQ("foo0,_Cookies,__C," | 740 EXPECT_STREQ("foo0,_Cookies,__C," |
| 553 "foo1,_Cookies,__B", | 741 "foo1,_Cookies,__B," |
| 742 "host1,_Local Storage,__origin1," |
| 743 "host2,_Local Storage,__origin2", |
| 554 GetDisplayedCookies(cookies_view).c_str()); | 744 GetDisplayedCookies(cookies_view).c_str()); |
| 555 } | 745 } |
| 556 | 746 |
| 557 TEST_F(CookiesViewTest, FilterRemove) { | 747 TEST_F(CookiesViewTest, FilterRemove) { |
| 558 net::CookieMonster* monster = profile_->GetCookieMonster(); | 748 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 559 monster->SetCookie(GURL("http://foo0"), "C=1"); | 749 monster->SetCookie(GURL("http://foo0"), "C=1"); |
| 560 monster->SetCookie(GURL("http://bar0"), "D=1"); | 750 monster->SetCookie(GURL("http://bar0"), "D=1"); |
| 561 monster->SetCookie(GURL("http://foo1"), "B=1"); | 751 monster->SetCookie(GURL("http://foo1"), "B=1"); |
| 562 monster->SetCookie(GURL("http://bar1"), "A=1"); | 752 monster->SetCookie(GURL("http://bar1"), "A=1"); |
| 563 monster->SetCookie(GURL("http://bar1"), "E=1"); | 753 monster->SetCookie(GURL("http://bar1"), "E=1"); |
| 564 CookiesView cookies_view(profile_.get()); | 754 CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_); |
| 755 mock_browsing_data_helper_->AddLocalStorageSamples(); |
| 756 mock_browsing_data_helper_->Notify(); |
| 757 |
| 565 EXPECT_STREQ("bar0,_Cookies,__D," | 758 EXPECT_STREQ("bar0,_Cookies,__D," |
| 566 "bar1,_Cookies,__A,__E," | 759 "bar1,_Cookies,__A,__E," |
| 567 "foo0,_Cookies,__C," | 760 "foo0,_Cookies,__C," |
| 568 "foo1,_Cookies,__B", | 761 "foo1,_Cookies,__B," |
| 762 "host1,_Local Storage,__origin1," |
| 763 "host2,_Local Storage,__origin2", |
| 569 GetDisplayedCookies(cookies_view).c_str()); | 764 GetDisplayedCookies(cookies_view).c_str()); |
| 570 EXPECT_STREQ("D,A,E,C,B", GetMonsterCookies(monster).c_str()); | 765 EXPECT_STREQ("D,A,E,C,B", GetMonsterCookies(monster).c_str()); |
| 571 | 766 |
| 572 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 767 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 573 | 768 |
| 574 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); | 769 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "bar"); |
| 575 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 770 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 576 // Entering text doesn't immediately filter the results. | 771 // Entering text doesn't immediately filter the results. |
| 577 EXPECT_STREQ("bar0,_Cookies,__D," | 772 EXPECT_STREQ("bar0,_Cookies,__D," |
| 578 "bar1,_Cookies,__A,__E," | 773 "bar1,_Cookies,__A,__E," |
| 579 "foo0,_Cookies,__C," | 774 "foo0,_Cookies,__C," |
| 580 "foo1,_Cookies,__B", | 775 "foo1,_Cookies,__B," |
| 776 "host1,_Local Storage,__origin1," |
| 777 "host2,_Local Storage,__origin2", |
| 581 GetDisplayedCookies(cookies_view).c_str()); | 778 GetDisplayedCookies(cookies_view).c_str()); |
| 582 | 779 |
| 583 // Results are filtered immediately if you activate (hit enter in the entry). | 780 // Results are filtered immediately if you activate (hit enter in the entry). |
| 584 gtk_widget_activate(cookies_view.filter_entry_); | 781 gtk_widget_activate(cookies_view.filter_entry_); |
| 585 EXPECT_STREQ("bar0,_Cookies,__D," | 782 EXPECT_STREQ("bar0,_Cookies,__D," |
| 586 "bar1,_Cookies,__A,__E", | 783 "bar1,_Cookies,__A,__E", |
| 587 GetDisplayedCookies(cookies_view).c_str()); | 784 GetDisplayedCookies(cookies_view).c_str()); |
| 588 | 785 |
| 589 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); | 786 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
| 590 EXPECT_STREQ("bar0,_Cookies,__D," | 787 EXPECT_STREQ("bar0,_Cookies,__D," |
| 591 "bar1,+Cookies,++A,++E", | 788 "bar1,+Cookies,++A,++E", |
| 592 GetDisplayedCookies(cookies_view).c_str()); | 789 GetDisplayedCookies(cookies_view).c_str()); |
| 593 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); | 790 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); |
| 594 | 791 |
| 595 { | 792 { |
| 596 SCOPED_TRACE("First selection"); | 793 SCOPED_TRACE("First selection"); |
| 597 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 794 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 598 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 795 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 599 CheckDetailsSensitivity(TRUE, cookies_view); | 796 CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
| 600 } | 797 } |
| 601 | 798 |
| 602 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 799 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 603 | 800 |
| 604 { | 801 { |
| 605 SCOPED_TRACE("First selection removed"); | 802 SCOPED_TRACE("First selection removed"); |
| 606 EXPECT_STREQ("D,E,C,B", GetMonsterCookies(monster).c_str()); | 803 EXPECT_STREQ("D,E,C,B", GetMonsterCookies(monster).c_str()); |
| 607 EXPECT_STREQ("bar0,_Cookies,__D," | 804 EXPECT_STREQ("bar0,_Cookies,__D," |
| 608 "bar1,+Cookies,++E", | 805 "bar1,+Cookies,++E", |
| 609 GetDisplayedCookies(cookies_view).c_str()); | 806 GetDisplayedCookies(cookies_view).c_str()); |
| 610 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 807 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 611 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 808 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 612 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); | 809 EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str()); |
| 613 CheckDetailsSensitivity(TRUE, cookies_view); | 810 CheckDetailsSensitivity(TRUE, FALSE, cookies_view); |
| 614 } | 811 } |
| 615 | 812 |
| 616 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 813 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 617 | 814 |
| 618 { | 815 { |
| 619 SCOPED_TRACE("Second selection"); | 816 SCOPED_TRACE("Second selection"); |
| 620 EXPECT_STREQ("D,C,B", GetMonsterCookies(monster).c_str()); | 817 EXPECT_STREQ("D,C,B", GetMonsterCookies(monster).c_str()); |
| 621 EXPECT_STREQ("bar0,_Cookies,__D," | 818 EXPECT_STREQ("bar0,_Cookies,__D," |
| 622 "bar1,+Cookies", | 819 "bar1,+Cookies", |
| 623 GetDisplayedCookies(cookies_view).c_str()); | 820 GetDisplayedCookies(cookies_view).c_str()); |
| 624 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 821 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 625 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 822 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 626 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); | 823 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); |
| 627 CheckDetailsSensitivity(FALSE, cookies_view); | 824 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 628 } | 825 } |
| 629 | 826 |
| 630 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); | 827 ASSERT_TRUE(ExpandByPath(cookies_view, "0")); |
| 631 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); | 828 ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); |
| 632 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 829 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 633 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); | 830 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 634 | 831 |
| 635 { | 832 { |
| 636 SCOPED_TRACE("Second selection removed"); | 833 SCOPED_TRACE("Second selection removed"); |
| 637 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); | 834 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); |
| 638 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); | 835 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 639 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); | 836 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 640 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); | 837 EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str()); |
| 641 CheckDetailsSensitivity(FALSE, cookies_view); | 838 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 642 EXPECT_STREQ("bar0,+Cookies," | 839 EXPECT_STREQ("bar0,+Cookies," |
| 643 "bar1,+Cookies", | 840 "bar1,+Cookies", |
| 644 GetDisplayedCookies(cookies_view).c_str()); | 841 GetDisplayedCookies(cookies_view).c_str()); |
| 645 } | 842 } |
| 646 | 843 |
| 647 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); | 844 gtk_button_clicked(GTK_BUTTON(cookies_view.filter_clear_button_)); |
| 648 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); | 845 EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 649 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); | 846 EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_))); |
| 650 EXPECT_STREQ("foo0,_Cookies,__C," | 847 EXPECT_STREQ("foo0,_Cookies,__C," |
| 651 "foo1,_Cookies,__B", | 848 "foo1,_Cookies,__B," |
| 849 "host1,_Local Storage,__origin1," |
| 850 "host2,_Local Storage,__origin2", |
| 652 GetDisplayedCookies(cookies_view).c_str()); | 851 GetDisplayedCookies(cookies_view).c_str()); |
| 852 |
| 853 gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); |
| 854 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); |
| 855 // Entering text doesn't immediately filter the results. |
| 856 EXPECT_STREQ("foo0,_Cookies,__C," |
| 857 "foo1,_Cookies,__B," |
| 858 "host1,_Local Storage,__origin1," |
| 859 "host2,_Local Storage,__origin2", |
| 860 GetDisplayedCookies(cookies_view).c_str()); |
| 861 |
| 862 // Results are filtered immediately if you activate (hit enter in the entry). |
| 863 gtk_widget_activate(cookies_view.filter_entry_); |
| 864 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 865 "host2,_Local Storage,__origin2", |
| 866 GetDisplayedCookies(cookies_view).c_str()); |
| 867 |
| 868 ASSERT_TRUE(ExpandByPath(cookies_view, "1")); |
| 869 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 870 "host2,+Local Storage,++origin2", |
| 871 GetDisplayedCookies(cookies_view).c_str()); |
| 872 ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); |
| 873 |
| 874 { |
| 875 SCOPED_TRACE("First selection"); |
| 876 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 877 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 878 CheckDetailsSensitivity(FALSE, TRUE, cookies_view); |
| 879 } |
| 880 |
| 881 gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); |
| 882 |
| 883 { |
| 884 SCOPED_TRACE("First selection removed"); |
| 885 EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); |
| 886 EXPECT_STREQ("host1,_Local Storage,__origin1," |
| 887 "host2,+Local Storage", |
| 888 GetDisplayedCookies(cookies_view).c_str()); |
| 889 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); |
| 890 EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); |
| 891 EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str()); |
| 892 CheckDetailsSensitivity(FALSE, FALSE, cookies_view); |
| 893 } |
| 653 } | 894 } |
| OLD | NEW |