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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc

Issue 973303002: [Extensions] Make chrome://extensions use developerPrivate for error calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" 6 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
7 #include "chrome/browser/extensions/extension_function_test_utils.h" 7 #include "chrome/browser/extensions/extension_function_test_utils.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h" 9 #include "chrome/browser/extensions/extension_service_test_base.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 unpacked_args.Append(options.release()); 365 unpacked_args.Append(options.release());
366 current_ids = registry()->enabled_extensions().GetIDs(); 366 current_ids = registry()->enabled_extensions().GetIDs();
367 EXPECT_FALSE(RunFunction(function, unpacked_args)); 367 EXPECT_FALSE(RunFunction(function, unpacked_args));
368 EXPECT_EQ(manifest_errors::kManifestUnreadable, function->GetError()); 368 EXPECT_EQ(manifest_errors::kManifestUnreadable, function->GetError());
369 // We should have no new extensions installed. 369 // We should have no new extensions installed.
370 EXPECT_EQ(0u, base::STLSetDifference<ExtensionIdSet>( 370 EXPECT_EQ(0u, base::STLSetDifference<ExtensionIdSet>(
371 registry()->enabled_extensions().GetIDs(), 371 registry()->enabled_extensions().GetIDs(),
372 current_ids).size()); 372 current_ids).size());
373 } 373 }
374 374
375 // Test developerPrivate.requestFileSource.
376 TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateRequestFileSource) {
377 ResetThreadBundle(content::TestBrowserThreadBundle::DEFAULT);
378 // Testing of this function seems light, but that's because it basically just
379 // forwards to reading a file to a string, and highlighting it - both of which
380 // are already tested separately.
381 const Extension* extension = LoadUnpackedExtension();
382 const char kErrorMessage[] = "Something went wrong";
383 api::developer_private::RequestFileSourceProperties properties;
384 properties.extension_id = extension->id();
385 properties.path_suffix = "manifest.json";
386 properties.message = kErrorMessage;
387 properties.manifest_key.reset(new std::string("name"));
388
389 scoped_refptr<UIThreadExtensionFunction> function(
390 new api::DeveloperPrivateRequestFileSourceFunction());
391 base::ListValue file_source_args;
392 file_source_args.Append(properties.ToValue().release());
393 EXPECT_TRUE(RunFunction(function, file_source_args)) << function->GetError();
394
395 const base::Value* response_value = nullptr;
396 ASSERT_TRUE(function->GetResultList()->Get(0u, &response_value));
397 scoped_ptr<api::developer_private::RequestFileSourceResponse> response =
398 api::developer_private::RequestFileSourceResponse::FromValue(
399 *response_value);
400 EXPECT_FALSE(response->before_highlight.empty());
401 EXPECT_EQ("\"name\": \"foo\"", response->highlight);
402 EXPECT_FALSE(response->after_highlight.empty());
403 EXPECT_EQ("foo: manifest.json", response->title);
404 EXPECT_EQ(kErrorMessage, response->message);
405 }
406
375 } // namespace extensions 407 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698