| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "ios/chrome/browser/snapshots/snapshots_util.h" | 5 #import "ios/chrome/browser/snapshots/snapshots_util.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 return numberOfMatches == 1; | 35 return numberOfMatches == 1; |
| 36 } | 36 } |
| 37 | 37 |
| 38 TEST(SnapshotsUtilTest, TestSnapshotList) { | 38 TEST(SnapshotsUtilTest, TestSnapshotList) { |
| 39 NSString* scaleModifier = @""; | 39 NSString* scaleModifier = @""; |
| 40 CGFloat scale = [UIScreen mainScreen].scale; | 40 CGFloat scale = [UIScreen mainScreen].scale; |
| 41 if (scale > 1) { | 41 if (scale > 1) { |
| 42 scaleModifier = [NSString stringWithFormat:@"@%.0fx", scale]; | 42 scaleModifier = [NSString stringWithFormat:@"@%.0fx", scale]; |
| 43 } | 43 } |
| 44 NSString* path = @"Main"; | 44 NSString* path = base::SysUTF8ToNSString(base::mac::BaseBundleID()); |
| 45 if (base::ios::IsRunningOnIOS8OrLater()) { | |
| 46 path = base::SysUTF8ToNSString(base::mac::BaseBundleID()); | |
| 47 } | |
| 48 NSString* filename = @"UIApplicationAutomaticSnapshotDefault-LandscapeRight"; | 45 NSString* filename = @"UIApplicationAutomaticSnapshotDefault-LandscapeRight"; |
| 49 NSString* regex = [NSString | 46 NSString* regex = [NSString |
| 50 stringWithFormat:@".*/%@/%@%@.png$", path, filename, scaleModifier]; | 47 stringWithFormat:@".*/%@/%@%@.png$", path, filename, scaleModifier]; |
| 51 EXPECT_FALSE(RegexMatchesOneSnapshotPath(@".*")); | 48 EXPECT_FALSE(RegexMatchesOneSnapshotPath(@".*")); |
| 52 EXPECT_FALSE(RegexMatchesOneSnapshotPath(@"foo")); | 49 EXPECT_FALSE(RegexMatchesOneSnapshotPath(@"foo")); |
| 53 EXPECT_TRUE(RegexMatchesOneSnapshotPath(@".*LandscapeRight.*")); | 50 EXPECT_TRUE(RegexMatchesOneSnapshotPath(@".*LandscapeRight.*")); |
| 54 EXPECT_TRUE(RegexMatchesOneSnapshotPath(regex)); | 51 EXPECT_TRUE(RegexMatchesOneSnapshotPath(regex)); |
| 55 } | 52 } |
| 56 | 53 |
| 57 } // anonymous namespace | 54 } // anonymous namespace |
| OLD | NEW |