| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/geolocation_exceptions_window_controller.h" | 5 #import "chrome/browser/cocoa/simple_content_exceptions_window_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "chrome/browser/cocoa/browser_test_helper.h" | 11 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 12 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 13 #include "chrome/browser/geolocation/geolocation_exceptions_table_model.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class GeolocationExceptionsWindowControllerTest : public CocoaTest { | 19 class SimpleContentExceptionsWindowControllerTest : public CocoaTest { |
| 19 public: | 20 public: |
| 20 virtual void SetUp() { | 21 virtual void SetUp() { |
| 21 CocoaTest::SetUp(); | 22 CocoaTest::SetUp(); |
| 22 TestingProfile* profile = browser_helper_.profile(); | 23 TestingProfile* profile = browser_helper_.profile(); |
| 23 settingsMap_ = new GeolocationContentSettingsMap(profile); | 24 settingsMap_ = new GeolocationContentSettingsMap(profile); |
| 24 } | 25 } |
| 25 | 26 |
| 26 GeolocationExceptionsWindowController* GetController() { | 27 SimpleContentExceptionsWindowController* GetController() { |
| 27 id controller = [GeolocationExceptionsWindowController | 28 GeolocationExceptionsTableModel* model = // Freed by window controller. |
| 28 controllerWithSettingsMap:settingsMap_.get()]; | 29 new GeolocationExceptionsTableModel(settingsMap_.get()); |
| 30 id controller = [SimpleContentExceptionsWindowController |
| 31 controllerWithTableModel:model]; |
| 29 [controller showWindow:nil]; | 32 [controller showWindow:nil]; |
| 30 return controller; | 33 return controller; |
| 31 } | 34 } |
| 32 | 35 |
| 33 void ClickRemoveAll(GeolocationExceptionsWindowController* controller) { | 36 void ClickRemoveAll(SimpleContentExceptionsWindowController* controller) { |
| 34 [controller removeAll:nil]; | 37 [controller removeAll:nil]; |
| 35 } | 38 } |
| 36 | 39 |
| 37 protected: | 40 protected: |
| 38 BrowserTestHelper browser_helper_; | 41 BrowserTestHelper browser_helper_; |
| 39 scoped_refptr<GeolocationContentSettingsMap> settingsMap_; | 42 scoped_refptr<GeolocationContentSettingsMap> settingsMap_; |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 TEST_F(GeolocationExceptionsWindowControllerTest, Construction) { | 45 TEST_F(SimpleContentExceptionsWindowControllerTest, Construction) { |
| 43 GeolocationExceptionsWindowController* controller = | 46 GeolocationExceptionsTableModel* model = // Freed by window controller. |
| 44 [GeolocationExceptionsWindowController | 47 new GeolocationExceptionsTableModel(settingsMap_.get()); |
| 45 controllerWithSettingsMap:settingsMap_.get()]; | 48 SimpleContentExceptionsWindowController* controller = |
| 49 [SimpleContentExceptionsWindowController controllerWithTableModel:model]; |
| 46 [controller showWindow:nil]; | 50 [controller showWindow:nil]; |
| 47 [controller close]; // Should autorelease. | 51 [controller close]; // Should autorelease. |
| 48 } | 52 } |
| 49 | 53 |
| 50 TEST_F(GeolocationExceptionsWindowControllerTest, AddExistingEditAdd) { | 54 TEST_F(SimpleContentExceptionsWindowControllerTest, AddExistingEditAdd) { |
| 51 settingsMap_->SetContentSetting( | 55 settingsMap_->SetContentSetting( |
| 52 GURL("http://myhost"), GURL(), CONTENT_SETTING_BLOCK); | 56 GURL("http://myhost"), GURL(), CONTENT_SETTING_BLOCK); |
| 53 | 57 |
| 54 GeolocationExceptionsWindowController* controller = GetController(); | 58 SimpleContentExceptionsWindowController* controller = GetController(); |
| 55 ClickRemoveAll(controller); | 59 ClickRemoveAll(controller); |
| 56 | 60 |
| 57 [controller close]; | 61 [controller close]; |
| 58 | 62 |
| 59 EXPECT_EQ(0u, settingsMap_->GetAllOriginsSettings().size()); | 63 EXPECT_EQ(0u, settingsMap_->GetAllOriginsSettings().size()); |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace | 66 } // namespace |
| OLD | NEW |